2177. Bronze Cow Party

单点时限: 2.0 sec

内存限制: 256 MB

One cow from each of N farms (1 <= N <= 1000) conveniently numbered 1..N is attending the big cow party to be held at farm #X (1 <= X <= N). Each of M (1 <= M <= 100,000) bidirectional roads connects one farm to another. It is always possible to travel from one farm to another on the roads. Traversing road i requires Ti (1 <= Ti <= 100) units of time. One or more pairs of farms might be directly connected by more than one road.

After all the cows gathered at farm #X, they realized that every single cow left her party favors back at the farm. They decided to suspend the party and send all the cows back to get the party favors. The cows all travel optimal routes to their home farm and back to the party. What is the minimum number of time units the party must be suspended?

输入格式

  • Line 1: Three space-separated integers, respectively: N, M, and X

  • Lines 2..M+1: Line i+1 describes road i with three space-separated integers, respectively: Ai, Bi, and Ti. The described road connects Ai and Bi and requires Ti time units to traverse.

输出格式

  • Line 1: One integer: the minimum amount of time the party must be suspended.

样例

Input
4 8 2
1 2 7
1 3 8
1 4 4
2 1 3
2 3 1
3 1 2
3 4 6
4 2 2
Output
6

15 人解决,28 人已尝试。

15 份提交通过,共有 104 份提交。

6.3 EMB 奖励。

创建: 16 年,11 月前.

修改: 6 年,7 月前.

最后提交: 9 月,1 周前.

来源: Elite 2007 US Open Competition

题目标签