#P1266. 速度限制
速度限制
Description
In this busy society, we often do not choose the shortest road but the fastest route. While driving, the speed limit of each road becomes the key factor. Unfortunately, some speed-limit signs are missing, so you cannot know how fast you should drive. A defensible approach is to keep driving at your previous speed. Your task is to compute the fastest route between two places.
You are given road traffic information for a modern city. To simplify the problem, the map includes only intersections and roads. Each road is directed, connects exactly two intersections, and has at most one speed-limit sign located at the start of the road. For any two intersections and , there is at most one road from to . You may assume instantaneous acceleration and no congestion or similar factors. Of course, your speed cannot exceed the current speed limit.
Input Format
The first line contains 3 integers , , and (, ). is the number of intersections, labeled from 0 to . is the total number of roads, and is your destination.
The next lines each describe one road, with 4 integers (), (), (), and (). This road goes from to , its speed limit is , and its length is . If is , the speed limit on this road is unknown.
If is not , the travel time is . Otherwise , where is your speed upon arriving at the intersection before this road. Initially, you are at 0 with speed 70.
Output Format
Output a single line of integers: the sequence of intersections you pass from 0 to , in order, starting with 0 and ending with , separated by spaces. There is only one fastest route.
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
Translated by ChatGPT 5
京公网安备 11011102002149号