The Widest Road Trip
A path's width is its narrowest road. Print the maximum possible width of a path from node 1 to node N, or −1 if disconnected.
Input: the first line has N and M; each of the next M lines has u v w (road width w).
Output: the maximum bottleneck width, or −1.
Constraints:
- 2 ≤ N ≤ 104
- 1 ≤ M ≤ 2×104
- 1 ≤ w ≤ 109
Sample Tests
Input 1
4 4 1 2 5 2 4 3 1 3 2 3 4 4
Output 1
3
Input 2
3 1 1 2 9
Output 2
-1
Discussion (opens after you solve — no spoilers before)
No comments yet.