Morning light hits the pine barrens of Needlepoint as Jaya unrolls the day's manifest of routes. The tally will decide the next shipment. Task: An undirected weighted graph is given. Print the shortest-path cost from s to t, or -1 if unreachable. Input format: First line: n m s t. Next m lines: u v w. Output format: Print the shortest distance or -1. Constraints: 1 <= n <= 1390; 0 <= m <= 4170; 1 <= s,t,u,v <= n; 0 <= w <= 1000000000; distance fits 64-bit.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 1390; 0 <= m <= 4170; 1 <= s,t,u,v <= n; 0 <= w <= 1000000000; distance fits 64-bit.
