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 1806. Mobile Telegraphs

TLE#11? Help...
Posted by caoyuan9642 5 Feb 2011 18:27
I used Dijkstra+heap optimized but still got TLE on #11..
Is there some better algorithm?
help..
my email:caoyuan@mail.ustc.edu.cn
thx.
Re: TLE#11? Help...
Posted by wRabbits_AlMag(VNTU) 1 Aug 2011 18:40
Try to use numbers instead of strings
Re: TLE#11? Help...
Posted by Karolis Kusas 8 Aug 2011 22:29
How to cope with the strings? I put all strings to a map, then for each string I construct all possible neighbours and then I check if they are in a map. So I have to deal with 50000 * 135 * 16 = 108 000 000 operations. It is too much. I can use a hash table. However, is there any simpler solution than using the hash table?
Re: TLE#11? Help...
Posted by renith 10 Jun 2016 15:18
You can use strings (because it's so conveniently), but you have to forget about std::map. Use unordered_map<string> (or your hash table) instead of it. I had TLE on test 11 with std::map, but when I changed map to unordered_map, I got AC with not bad time. I think it's easier than use numbers instead of strings.