Graph Contest 3 P2 - Shortest Path
View as PDFGiven a directed graph, find the length of the shortest path from  to 
.
Input Specification
, the number of vertices.
, the number of edges.
 lines, each with three integers 
, 
, 
 
 indicating a directed edge from 
 to 
 of length 
.
Bonus: one case will have edges with negative lengths.
A shortest path will always exist.
Output Specification
The length of the shortest path from vertex  to vertex 
.
Sample Input
3 3
1 2 1
2 3 2
1 3 5
Sample Output
3
Take the path .
Comments