#P1396. 营救
营救
Description
When Mom came home from work, the neighbors said that Xiaoming had been forced into a police car by a group of strangers. With her experience, she inferred that Xiaoming was taken to district , while she herself is in district .
The city has avenues connecting districts. Each avenue connects two districts and has a congestion level. Although Xiaoming’s mom is in a hurry, she does not want the crowded flow to disrupt her elegant pace. Please help her plan a route from to such that the maximum congestion level among the avenues on the route is minimized.
Input Format
The first line contains four space-separated integers , , , , whose meanings are as described above.
The next lines each contain three integers , indicating there is an avenue connecting districts and with congestion level .
There may be multiple avenues between two districts.
Output Format
Output a single integer: the minimal possible value of the maximum congestion level along the chosen route.
3 3 1 3
1 2 2
2 3 1
1 3 3
2
Hint
Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , , . It is guaranteed that from one can reach district .
Explanation for Sample 1
Xiaoming’s mom needs to go from point 1 to point 3. An optimal route is 1 -> 2 -> 3.
Translated by ChatGPT 5
京公网安备 11011102002149号