#P7271. [BalticOI 2002] Speed Limits (Day1)
[BalticOI 2002] Speed Limits (Day1)
Description
You are now at node in an undirected graph with nodes and edges. The nodes are numbered from to .
Each edge connects and , with speed limit and length . The time to pass this edge is computed as follows:
$$T=\begin{cases}\dfrac{L}{V}\ (V\ne 0)\\\dfrac{L}{V_\text{old}}\ (V=0)\end{cases}$$Here, is the value of on the previous edge you passed. Initially, .
If , then after computing , the value of on this edge is updated to , and is updated to .
You want to go from node to node . Find a path from to that minimizes the total travel time.
Input Format
The first line contains three integers , representing the number of nodes, the number of edges, and the destination node.
The next lines each contain four integers , representing an edge.
Output Format
Output one line with several integers, representing a path with the minimum total travel time.
6 15 1
0 1 25 68
0 2 30 50
0 5 0 101
1 2 70 77
1 3 35 42
2 0 0 22
2 1 40 86
2 3 0 23
2 4 45 40
3 1 64 14
3 5 0 23
4 1 95 8
5 1 0 84
5 2 90 64
5 3 36 40
0 5 2 3 1
Hint
Sample Explanation
For sample , the time spent on the output path is the smallest, which is .
Constraints
For of the testdata, , .
Note
Translated from BalticOI 2002 Day1 A Speed Limits。
Translated by ChatGPT 5
京公网安备 11011102002149号