2034: 最短路

Memory Limit:256 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

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