Pro.ID21045 TitleFDNY to the Rescue! Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21045 AC3 Submit770 Ratio0.39% 时间&空间限制描述The Fire Department of New York (FDNY) has always been proud of their response time to fires in New York City, but they want to make their response time even better. To help them with their response time, they want to make sure that the dispatchers know the closest firehouse to any address in the city. You have been hired to write this software and are entrusted with maintaining the proud tradition of FDNY. Conceptually, the software will be given the address of the fire, the locations of the firehouses, street intersections, and the time it takes to cover the distance between each intersection. It will then use this information to calculate how long it takes to reach an address from each firehouse. 输入Line 1:
输出Description The Fire Department of New York (FDNY) has always been proud of their response time to fires in New York City, but they want to make their response time even better. To help them with their response time, they want to make sure that the dispatchers know the closest firehouse to any address in the city. You have been hired to write this software and are entrusted with maintaining the proud tradition of FDNY. Conceptually, the software will be given the address of the fire, the locations of the firehouses, street intersections, and the time it takes to cover the distance between each intersection. It will then use this information to calculate how long it takes to reach an address from each firehouse. Input Line 1:
Output Line 1: Notes on output format: 1. Columns are tab separated. 2. If two or more firehouses are tied in time they can be printed in any order. 3. If more than one path exists that has the same minimal time for a given location & firehouse, either one can be printed on the output. 4. If the fire location and the fire station locations happen to be the same intersection, the output will indicate that the origin and destination have the same intersection number, the time will be "0" and the nodes in the shortest path will show just one number, the fire location.
Sample Input 6
0 3 4 -1 -1 -1
-1 0 4 5 -1 -1
2 3 0 -1 -1 2
8 9 5 0 1 -1
7 2 1 -1 0 -1
5 -1 4 5 4 0
2 4 5 6 In the above input the last line indicates that "2" is the location of the fire and "4", "5" and "6" are the intersections where fire stations are located. Sample Output Org Dest Time Path
5 2 2 5 2
4 2 3 4 5 2
6 2 6 6 5 2 Source 样例输入6
0 3 4 -1 -1 -1
-1 0 4 5 -1 -1
2 3 0 -1 -1 2
8 9 5 0 1 -1
7 2 1 -1 0 -1
5 -1 4 5 4 0
2 4 5 6 In the above input the last line indicates that "2" is the location of the fire and "4", "5" and "6" are the intersections where fire stations are located. 样例输出Org Dest Time Path
5 2 2 5 2
4 2 3 4 5 2
6 2 6 6 5 2 作者 |