Distance betweeen the vertices
Very easy
Execution time limit is 2 seconds
Runtime memory usage limit is 128 megabytes
An undirected weighted graph is given. Find the length of the shortest path between two specified vertices.
Input
The first line contains two positive integers and — the number of vertices and edges in the graph. The second line contains two positive integers and — the numbers of the vertices between which you need to find the shortest path.
The following lines contain the descriptions of the edges. Each edge is described by three integers , and — the numbers of the vertices it connects and its weight.
Output
Print the weight of the shortest path between vertices and , or if no such path exists.
Examples
Input #1
Answer #1
Submissions 2K
Acceptance rate 35%