#C3663. Maximum Weight Path
Maximum Weight Path
Maximum Weight Path
You are given a network of planets connected by bidirectional tunnels. Each tunnel has a weight capacity that represents the maximum weight that can pass through it safely. Given two specific planets, a starting planet E and a destination planet C, your task is to determine the maximum weight of mineral that can be transported from planet E to planet C. The weight that can be transported along a particular route is limited by the tunnel with the smallest capacity along that path.
If there is no possible path between E and C, then the answer is 0.
Hint: Consider using a modified Dijkstra's algorithm using a maximum-priority queue, where you update the best (maximum minimum) capacity available for each planet.
inputFormat
The input consists of multiple datasets. Each dataset is structured as follows:
- The first line contains two integers n and m, representing the number of planets and tunnels respectively.
- The second line contains two integers E and C, the starting planet and the destination planet respectively.
- The following m lines each contain three integers A, B and W indicating that there is a tunnel between planet A and planet B with capacity W.
The input terminates with a line containing "0 0".
outputFormat
For each dataset, output a single line containing the maximum weight that can be safely transported from planet E to planet C. If there is no valid path, output 0.
## sample4 4
1 4
1 2 5
2 3 8
3 4 6
1 3 4
0 0
5
</p>