Given a directed graph with non-negative edge weights, find the shortest distance from a source to a destination.
Input: line 1 — n m (nodes 0..n-1, edge count); next m lines — u v w (edge u→v with weight w); last line — source destination.
Output: the shortest distance, or -1 if the destination is unreachable.
Your program reads from stdin and prints to stdout.
Given a directed graph with non-negative edge weights, find the shortest distance from a source to a destination.
Input: line 1 — n m (nodes 0..n-1, edge count); next m lines — u v w (edge u→v with weight w); last line — source destination.
Output: the shortest distance, or -1 if the destination is unreachable.
Your program reads from stdin and prints to stdout.