#P11964. Reachable Vertices Count

    ID: 14074 Type: Default 1000ms 256MiB

Reachable Vertices Count

Reachable Vertices Count

Given an undirected graph with nn vertices and mm edges (vertices are numbered 1,2,,n1,2,\dots,n), you need to answer the following: For each vertex ii (1in1\le i\le n), if you start at vertex ii and move exactly jj steps (where 1jk1\le j\le k) with each move going to any adjacent vertex, compute the number of distinct vertices you can reach. Formally, let S(i,j)\mathcal{S}(i, j) be the set of vertices that can be reached from vertex ii in exactly jj moves. You only need to output the size of S(i,j)\mathcal{S}(i, j) for each vertex ii and each step count jj.

inputFormat

The input begins with a single line containing three integers nn, mm, and kk, where:

  • $n$ is the number of vertices,
  • $m$ is the number of edges, and
  • $k$ is the maximum number of moves to simulate.
Each of the following $m$ lines contains two integers $u$ and $v$, representing an undirected edge connecting vertices $u$ and $v$.

outputFormat

Output nn lines. The ii-th line must contain kk integers separated by spaces, where the jj-th integer is the number of distinct vertices that can be reached from vertex ii in exactly jj moves.

sample

3 2 2
1 2
2 3
1 2

2 1 1 2

</p>