Directed Acyclic Graph

View as PDF

Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 16M

Problem type

Given a directed graph, output YES if it is acyclic, and NO otherwise.

Input Specification

As usual.
N \le 1\,000.

Output Specification

YES or NO.

Sample Input

3
0 1 0 
0 0 1
1 0 0

Sample Output

NO

Sample Input 2

3
0 1 0
0 0 1
0 0 0

Sample Output 2

YES

Comments

There are no comments at the moment.