eolymp
bolt
Try our new interface for solving problems
Problems

Transitive closure

Transitive closure

Find the transitive closure of the directed graph. \InputFile The directed graph is given with the list of edges. The first line contains the number of vertices $n~(1 \le n \le 100)$. Each of the next lines contains two vertices $a$ and $b~(1 \le a, b \le n)$ describing the directed edge from $a$ to $b$. \OutputFile Print the adjacency matrix of the transitive closure of the directed graph. \includegraphics{https://static.e-olymp.com/content/d6/d628e96fa6f4577b626b3a366e764266b3f28271.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
4
4 1
1 2
3 4
Output example #1
0 1 0 0 
0 0 0 0 
1 1 0 1 
1 1 0 0 
Author Mykhailo Medvediev