#t510. 最短路
最短路
Shortest Path in a Weighted Undirected Graph
Special for beginners, ^_^
Problem Description
Given a weighted undirected graph with edges and vertices. Find the shortest path from vertex to vertex .
Input Format
The first line: (, ).
The next lines each contain positive integers , meaning there is a road of length between and , with .
Output Format
One integer: the shortest distance from to .
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 to .
Constraints
1s, 1024KiB for each test case.