ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1542. Autocompletion

N log^2 N - TLE
Posted by Crazy_serbs 21 Apr 2007 17:28
Hi,

i coulnd't find anything better than N log^2 N solution for this taks, but it gives me TLE at 12 test case.
Any hint for better approach?
Re: N log^2 N - TLE
Posted by forest 21 Apr 2007 17:57
all strings are up to 15 characters long, so i used preprocessing for each of the length
Re: N log^2 N - TLE
Posted by N.M.Hieu ( DHSP ) 21 Apr 2007 18:19
Mine is O( NlogN + MlogM + (N*15)logM ).
It still got AC , and of course , not so fast ( ~ 2.8 s ).
It can be faster but that's enough.
I think you should optimize your code . Your complexity is fast enough.
Re: N log^2 N - TLE
Posted by Kaliningrad SU -Dmitry-HeadLiner 21 Apr 2007 18:30
Is it smart search on the tree or I can use binary search with some precalculations?
Re: N log^2 N - TLE
Posted by Todor Tsonkov 21 Apr 2007 18:32
Can you explain in details the preprocessing of the strings ?
Re: N log^2 N - TLE
Posted by forest 21 Apr 2007 19:03
for each _len_ length of a string sort the original array using following ordering:
1. first _len_ chars of a string
2. number of times it is encountered, desc
2. whole string
Re: N log^2 N - TLE
Posted by Kaliningrad SU -Dmitry-HeadLiner 22 Apr 2007 16:42
I do the same but still have TLE on this server :(
Although my computer process any test within 2.6 s



Edited by author 22.04.2007 16:48