April Fools' Day Contest 3 P9 - Path Shortest Source Single
View as PDFWe ran out of ideas, so here's a template single source shortest path problem.
Given a graph with
nodes and
directed edges, where the
edge goes from node
to
with weight
, compute the minimum cost to reach each node starting from node
. It is guaranteed that all nodes are reachable from node
.
Constraints
It is guaranteed that all nodes are reachable from node .
Output Specification
The first line contains two space-separated integers, and
, the number of nodes and the number of directed edges in the graph.
The next lines each contain three space-separated integers, the
line containing
,
, and
, indicating that there is an edge from node
to
with weight
.
Input Specification
The first line contains space-separated integers, where the
integer is the minimum cost to reach node
starting from
node
.
Sample Output
6 6
1 2 4
1 3 7
2 3 2
2 4 5
3 6 1
6 5 2
Sample Input
0 4 6 9 7 8
Comments