#K3311. Minimum Towing Cost
Minimum Towing Cost
Minimum Towing Cost
You are given a set of towns connected by bidirectional roads, each associated with a towing cost. Your car has broken down in town C. The task is to determine the minimum cost to tow your car from town C to any other town.
This is a shortest path problem in an undirected weighted graph. Mathematically, if we denote the distance (towing cost) from town C to any town i by \(d(C,i)\), then you need to compute
$$\min_{i \neq C} d(C,i)$$
You may assume that there is always at least one town other than the starting town and that a path exists from town C to every other town.
inputFormat
The input is provided via standard input. The first line contains three integers separated by spaces: T (the number of towns), R (the number of roads), and C (the starting town index where your car is broken down).
This is followed by R lines. Each line contains three space-separated integers: A, B, and P, representing a road between town A and town B with a towing cost of P.
outputFormat
Output a single integer to standard output — the minimum towing cost from town C to any other town.
## sample4 4 0
0 1 10
1 2 20
2 3 30
0 3 25
10
</p>