Breadth First Search 0-1
Very easy
Execution time limit is 3 seconds
Runtime memory usage limit is 128 megabytes
An undirected graph is given. The weight of its edges can be or only. Find the shortest distance between vertices and .
Input
The first line contains four integers: the number of vertices , the number of edges , and the vertex numbers and . Each of the following lines contains three integers , , and , representing an undirected edge with an integer weight .
Output
Print the shortest distance between vertices and .
Examples
Input #1
Answer #1
Submissions 2K
Acceptance rate 48%