Given a directed graph, output YES
if it is acyclic, and NO
otherwise.
Input Specification
, the number of vertices.
An adjacency matrix, rows with numbers (0
or 1
).
Output Specification
YES
or NO
.
Sample Input 1
3
0 1 0
0 0 1
1 0 0
Sample Output 1
NO
Sample Input 2
3
0 1 0
0 0 1
0 0 0
Sample Output 2
YES
Comments