Transitivity of directed graph
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
The directed graph is called transitive, if for its any three distinct vertices and from the fact that there are edges from to and from to it follows that there is an edge from to .
Check that the given directed graph is transitive.
Input
The first line contains the number of vertices in the graph. The next lines contain the adjacency matrix of the graph.
Output
Print "YES" if graph is transitive and "NO" otherwise.
Examples
Input #1
Answer #1
Submissions 2K
Acceptance rate 51%