Problem Y: 【信息学奥赛一本通】最短路(Spfa)
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:91
Solved:45
Description
给定 M 条边, N 个点的带权无向图。求 1到 N 的最短路。
Input
第一行:N,M(N≤100000,M≤500000);
接下来M行3个正整数:ai,bi,ci表示ai,bi之间有一条长度为ci的路,ci≤1000。
Output
一个整数,表示 1 到 N 的最短距离。
Sample Input Copy
4 4
1 2 1
2 3 1
3 4 1
2 4 1
Sample Output Copy
2
HINT
【样例解释】
注意图中可能有重边和自环,数据保证 11到 NN有路径相连。