To restore shortest paths, create an array of "ancestors" \(p[]\) span>, in which, for each vertex, store the number of the vertex by which we hit this vertex.
N
0
1
L
-1
1000 ms 32 Mb Rules for program design and list of errors in automatic problem checking