Given a directed graph, compute in how many ways every vertex is reachable from the vertex 0 making the minim number of steps.
Input consists of several cases, each one with the number of vertices (between 1 and ), the number of arcs (between 0 and ), and pairs to indicate an arc from to . There are no repeated arcs, nor of the kind . Vertices are numbered from 0 to .
For every case, and for every vertex , print its number, the minimum number of steps to reach starting from 0, and in how many different ways this can be done. Print a -1 if a vertex is unreachable from 0. Print an empty line after every case.
Author: Unknown
Translator: Salvador Roura
Generation: 2026-01-25T11:56:14.974Z
© Jutge.org, 2006–2026.
https://jutge.org