The Unique Topological Sort
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
An unweighted directed graph is given. Determine whether it has a unique topological sort.
Input
The first line contains the number of vertices and the number of edges in the graph. The following lines describe the edges of the graph, each represented by a pair of integers — the indices of the start and end vertices.
Output
Print "YES" if there is a unique topological sort of the vertices, and "NO" if there are multiple valid sorts. If a topological sort is impossible, print .
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 664
Acceptance rate 38%