#P7271. [BalticOI 2002] Speed Limits (Day1)

[BalticOI 2002] Speed Limits (Day1)

Description

You are now at node 00 in an undirected graph with NN nodes and MM edges. The NN nodes are numbered from 00 to N1N-1.

Each edge connects AA and BB, with speed limit VV and length LL. 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, VoldV_\text{old} is the value of VV on the previous edge you passed. Initially, Vold=70V_\text{old}=70.

If V=0V=0, then after computing TT, the value of VV on this edge is updated to VoldV_\text{old}, and VoldV_\text{old} is updated to VV.

You want to go from node 00 to node DD. Find a path from 00 to DD that minimizes the total travel time.

Input Format

The first line contains three integers N,M,DN,M,D, representing the number of nodes, the number of edges, and the destination node.
The next MM lines each contain four integers A,B,V,LA,B,V,L, 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 11, the time spent on the output path is the smallest, which is 26282628.

Constraints

For 100%100\% of the testdata, 2MN1502 \le M \le N \le 150, 0V,L5000 \le V,L \le 500.

Note

Translated from BalticOI 2002 Day1 A Speed Limits

Translated by ChatGPT 5