Shortest even path
Very easy
Execution time limit is 2 seconds
Runtime memory usage limit is 128 megabytes
Undirected unweighted graph is given. Find the shortest path between two vertices of even length.
Input
The first line contains four integers: number of vertices , number of edges , source and destination . Each of the next lines contains two integers and describing an undirected edge .
Output
Print the shortest distance from to . The length of the path (number of edges in the path) must be even. If there is no path of even length between and , print .
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 436
Acceptance rate 44%