eolymp
bolt
Try our new interface for solving problems
Problems

Transitivity of directed graph

Transitivity of directed graph

The directed graph is called \textbf{transitive}, if for its any three distinct vertices $u, v$ and $w$ from the fact that there are edges from $u$ to $v$ and from $v$ to $w$ it follows that there is an edge from $u$ to $w$. Check that the given directed graph is transitive. \InputFile The first line contains the number of vertices $n~(1 \le n \le 100)$ in the graph. The next $n$ lines contain the adjacency matrix of the graph. \OutputFile Print "\textbf{YES}" if graph is transitive and "\textbf{NO}" otherwise.
Time limit 1 second
Memory limit 128 MiB
Input example #1
5
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
Output example #1
YES