Processing math: 100%
Second shortest path - MarisaOJ: Marisa Online Judge

Second shortest path

Time limit: 1000 ms
Memory limit: 256 MB
Given an undirected connected graph with n vertices and m edges, find the second shortest path from 1 to n. The length of this path must be greater than the shortest path. ### Input - The first line contains two integers n and m. - The next m lines each contain three integers u, v, and w, indicating a path of length w between u and v. ### Output - Print an integer representing the length of the second shortest path. ### Constraints - 1≤n,m≤105. - 1≤u,v≤n. - 1≤w≤104. ### Example Input: 4412100242002325034100 Output: 450