2992 - 2024_IDS_Spring_Lab7 Scoreboard

Time

2024/04/15 00:00:00 2024/04/22 00:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14297 2024_IDS_Spring_Lab7_Is DAG

14297 - 2024_IDS_Spring_Lab7_Is DAG   

Description

In graph theory, a directed acyclic graph (DAG) is a directed graph with no directed cycles.

Given a directed graph G = (V, E), note that:
- For any two vertices u, v in V, there may not exists path from u to v.
- G doesn't have multiple edges and self-loops.

V is a set of n vertices, denoted by 1, 2, ..., n.

E is a set of m edges, and each edge is represented by two ordered vertices u, v, which denotes an edge from vertex u to vertex v.

Please answer if graph G is a directed acyclic graph (DAG) or not.

Input

The first line contains two integers n and m — the size of V and the size of E.

Each of the following m lines contains two integers ui and vi, being an edge in E.

Restrictions

- 2 n 105
- 1 ≤ m ≤ min(n * (n - 1) / 2, 2 * 105)
- 1 ≤ ui, vi ≤ n, ui ≠ vi for 1 ≤ i ≤ m

Output

Output one line.

If graph G is DAG, output "YES". Otherwise, output "NO".

Sample Input  Download

Sample Output  Download

Tags




Discuss