Processing math: 100%
Finding the path - MarisaOJ: Marisa Online Judge

Finding the path

Time limit: 1000 ms
Memory limit: 256 MB
Given a undirected graph of n vertices and m edges. Find the shortest path from 1 and n. It is guaranteed that n is reachable from 1. ### Input - The first line contains 2 integers n,m. - The next m lines, each line contains 2 integers u,v, there is an edge between those vertices. ### Output - First print the length of the shortest path on one line. Then print the shortest path starting from 1 and ending at n. If there are more than 1 solution, print any. ### Constraints - 1≤n,m≤105. - 1≤u,v≤105. ### Example Input: 551213534332 Output: 2135