#Q77. 「一本通 3.2 练习 1」农场派对

「一本通 3.2 练习 1」农场派对

Description

Original source: USACO 2007 Feb. Silver

N(1N1000)N (1 \le N \le 1000) cows are going to attend a party held at the farm of cow numbered x(1xN)x(1 \le x \le N). There are M(1M100000)M(1\le M \le 100000) directed roads, each with a length of Ti(1Ti100)T_i(1 \le T_i \le 100). Every cow must attend the party and then return home, and each cow will choose the shortest path. Find the length of the longest shortest path (a round trip) among all NN cows. Special note: there may be multiple edges with different weights.

Input Format

Line 11: 33 space-separated integers N,M,XN,M,X;

Lines 2M+12 \ldots M+1: 33 space-separated integers Ai,Bi,TiA_i, B_i, T_i, indicating a road from AiA_i to BiB_i with length TiT_i.

Output Format

A single integer representing the length of the longest shortest path.

Sample 1

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