I thought, "Connecting stations will have more than one designation" means I should not change line If I start at a 'connecting station', but not that line, what should I use. It would be closer to the real life...
Thanks!
My program gives the correct answers for all of the examples and the cases quoted here and yet I still get a WA. I have tried all of the test cases I can think of, along similar lines to those here and can't find anything wrong. Does anyone have a more complete/complex test case I can try ?
I have no C-compiler at hand, so I did a little 'mind-debugging'.
Consider the input:
3
A:a=Cabcdefg=Bb
B:a=Cbb=Ag
C:a=Aab=Ca
BbAa
#
The correct answer is:
8:Bba=Cba=Aa
but I think your program produces:
8:Bb=Agfedcba
Your floodfill fills mtime['Ag'] with 6 and mtime['Ba'] with 7. Both values are correct, but the correct route is via the higher mtime['Ba'], while your routefinder selects the lower mtime['Ag'].
I hope I have made no mistakes. I haven't solved the problem yet, so I have no way of checking my assumptions...
hi yourself!
't was just a thought.
Sure, there is only one shortest route in the input I made up, the route via 'Ag' is longer (9) then via 'Ba' (8). I just didn't see your routefinder rule out traveling from 'Bb' (mtime=8) to 'Ag' (mtime=6), since conn['Bb']['Ag']==1 (it's a station), while the actual time is 3 seconds.
Nevermind.
Thx for putting a link to this contest on your site. I'm completely hooked eversince... :)
thanks xenon,
you saved me
your idea was right in principle, when i was backtracing the route it was possible for one to have lower time but not be part of the final route since it had to be either 3 less or 1 less and in the same major section to be on the route. solved now i just need to get rid of a few more wa's.......
Guess it's enough either to save an extra predecessor field while floodfilling, then backtracking always gives the correct route, or recheck the moves while stepping back, and then your code will work. I'll take the liberty to leech your program (is to leech an english verb?), of which I saved a copy , and translate your ideas into pascal, and submit it as my own
Happy hunting!
Actually, i just made two checks: either the step back reduces the cost by 3, or it reduces the cost by 1 and is on the same major route. No, I dont mind, it helps save time
In the end i decided to start anew and try something Dijkstra-ish. Took me 3 hours to implement it . But it got accepted and runs twice as fast using twice as much memory. Still wonder how the other guys can do it in zero CPU-time with 64k memory.
TTYL - xenon