Graph Contest 2 P2 - 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

N1000, the number of vertices.
An adjacency matrix, N rows with N numbers (0 or 1).

Output Specification

YES or NO.

Sample Input 1

Copy
3
0 1 0
0 0 1
1 0 0

Sample Output 1

Copy
NO

Sample Input 2

Copy
3
0 1 0
0 0 1
0 0 0

Sample Output 2

Copy
YES

Comments

There are no comments at the moment.