|
|
вернуться в форумDo you know a faster algorithm? If I try to check every way of placing words, I get 'Time limit exceeded' on test 5, and if I just first sort the words by lengths, and then try to find the first way of placing words and give it as answer, I get 'Wrong answer' on test 3. Could you please help me? Re: Do you know a faster algorithm? Dynamic programming Re: Do you know a faster algorithm? Try to create determinated finite automaton in graph realization. Use binary search to find the words in dictionary. Re: Do you know a faster algorithm? Послано CP GS 23 сен 2008 00:58 The Aho-Corasick algorithm will do it with linear time. Re: Do you know a faster algorithm? Thank you. I'll try :) Re: Do you know a faster algorithm? Послано yzthz 15 мар 2009 20:57 Unfortunately, I got TLE on the 8th input even if I implemented DP. Oh I know the reason. When two or more strings map to one series of number, since any solutions are qualified, it is possible to choose only one. Also, a compartmentalization to which position(0-s.length()) the string can fit in is recommended. Edited by author 16.03.2009 10:20 Re: Do you know a faster algorithm? can you please give me one test case where you sort the words by length and you get wrong answer? (i used similar technique and got wrong ans for test 3 as well) |
|
|