I know this problem is not going to be easy to get to pass in Java, but I see 3 others have done it, so I know it's possible. I've written an efficient scanner for the input, so that's not my time crunch. I'm wondering what other optimizations can be made to this problem to get it to pass in time. I'm using Dijkstra's with a priority queue as given by this pseudo-code: topcoder.com/tc?module=Stati ... #dijkstra223.
I'm using an array of adjacency list's to store the graph, each of which holds a pair of integers (the node and the distance). I'm thinking if I can remove the overhead of all the object creation of the pairs I might be better off, but I'm not sure how I can do that for this problem without introducing new overhead with division and mod by using a mapping of to a single integer value. Any and all ideas are welcome. Thanks.
Oh, and as a reference, right now my solution runs in ~12 seconds (as determined from testing on TSHPATH).
created
last reply
- 5
replies
- 1.2k
views
- 4
users
- 3
links