##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
You are given a connected undirected graph with vertices and edges.
The edges are indexed from to in the order they are given.
A path from vertex to vertex is called good if it has the minimum possible number of edges among all paths from vertex to vertex .
Two good paths ending at the same vertex are compared lexicographically by the sequence of edge indices along the path from vertex to that vertex.
For each vertex , find the second smallest good path ending at . If it exists, output the sum of the indices of the edges used in that path. Otherwise, output .
For vertex , the answer is always .
There may be multiple edges between the same pair of vertices. Self-loops are not allowed.
For vertex , the shortest paths have length . There is only one good path: edge-index sequence , with vertex sequence . Therefore, there is no second good path.
For vertex , the shortest paths have length . The first good path has edge-index sequence , and the second one has edge-index sequence . Both have vertex sequence , because the two edges are parallel. So the answer for vertex is .
For vertex , the shortest paths have length . The first good path has edge-index sequence , with vertex sequence . The second one has edge-index sequence , also with vertex sequence . So the answer for vertex is .
For vertex , the shortest paths have length . The first good path has edge-index sequence , with vertex sequence . The second one has edge-index sequence , with vertex sequence . So the answer for vertex is .
For vertex , the first two good paths have edge-index sequences and , so the answer is .
For vertex , the first two good paths have edge-index sequences and , so the answer is .
For vertex , the first two good paths have edge-index sequences and , so the answer is .
For vertex , the first two good paths have edge-index sequences and , so the answer is .
For vertex , the first two good paths have edge-index sequences and , so the answer is .
For vertex , there is only one good path, with edge-index sequence , so the answer is .