#t510. 最短路

最短路

Shortest Path in a Weighted Undirected Graph

Special for beginners, ^_^

Problem Description

Given a weighted undirected graph with MM edges and NN vertices. Find the shortest path from vertex 11 to vertex NN.

Input Format

The first line: N,MN,M (N≤100000N\le100000, M≤500000M\le500000).

The next MM lines each contain 33 positive integers ai,bi,cia_i,b_i,c_i, meaning there is a road of length cic_i between aia_i and bib_i, with ci≤1000c_i\le1000.

Output Format

One integer: the shortest distance from 11 to NN.

Sample Input 1

4 4
1 2 1
2 3 1
3 4 1
2 4 1

Sample Output 1

2

Hint

Note that the graph may contain multiple edges and self-loops. The data guarantees that there is a path connecting 11 to NN.

Constraints

1s, 1024KiB for each test case.