#P1821. [USACO07FEB] Cow Party S
[USACO07FEB] Cow Party S
Description
Winter break has arrived, and cows are going to attend a party held at the farm of the cow numbered . There are directed roads between farms, and each road has a certain length.
After the party, every cow must return home. Whether going to the party or going back home, each cow will choose the shortest path. Among these cows, find the maximum length of a shortest round-trip path.
Input Format
The first line contains three integers representing the number of cows , the number of roads , and the party farm index .
The next lines each contain three integers , indicating that there is a road from to with length .
Output Format
Output one line with one integer representing the answer.
4 8 2
1 2 4
1 3 2
1 4 7
2 1 1
2 3 5
3 1 2
3 4 4
4 2 3
10
Hint
Sample 1 Explanation

Constraints For all test points, it is guaranteed that , , , . It is guaranteed that from any node you can reach node , and from you can reach all other nodes.
Translated by ChatGPT 5
京公网安备 11011102002149号