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

N \le 1\,000, the number of vertices.
An adjacency matrix, N rows with N 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

There are no comments at the moment.