SHPATH - The Shortest Path
You are given a list of cities. Each direct connection between two cities has its transportation cost (an integer bigger than 0). The goal is to find the paths of minimum cost between pairs of cities. Assume that the cost of each path (which is the sum of costs of all direct connections belongning to this path) is at most 200000. The name of a city is a string containing characters a,...,z and is at most 10 characters long.
s [the number of tests <= 10] n [the number of cities <= 10000] NAME [city name] p [the number of neighbours of city NAME] nr cost [nr - index of a city connected to NAME (the index of the first city is 1)] [cost - the transportation cost] r [the number of paths to find <= 100] NAME1 NAME2 [NAME1 - source, NAME2 - destination] [empty line separating the tests]
cost [the minimum transportation cost from city NAME1 to city NAME2 (one per line)]
Input: 1 4 gdansk 2 2 1 3 3 bydgoszcz 3 1 1 3 1 4 4 torun 3 1 3 2 1 4 1 warszawa 2 2 4 3 1 2 gdansk warszawa bydgoszcz warszawa Output: 3 2
Warning: large Input/Output data, be careful with certain languages
|Added by:||Darek Dereniowski|
|Cluster:||Cube (Intel Pentium G860 3GHz)|
|Languages:||All except: SCM chicken|
|Resource:||DASM Programming League 2003 (problemset 11)|
2 tle , 2 re , 4 wa, finally acc .... smile restored
I am curious how they made it within 0.00s. it takes more than it for just reading the input.
I got A/C using C++ 4.9 but TLE with 4.3.2. My running time was 1.44.Last edit: 2015-02-27 09:33:29
hard to get AC...Use TSHPATH to experiment...
Shubham Depp Bansal:
Please clarify whether transportation cost from X1 to X2 may be different from that of from X2 to X1 (input format allows that, but in real life that would sound a little absurd).
@J: For more advice go to the forum, here we would be just guessing what may be the slow part of your code, but as an additional note, check how you are making the I/O.