NOI Contest Archive

Archive / 2021 / Selection Test

Building the artifact

Easy · National Olympiad in Informatics Sri Lanka - Screening Test 2021

Captain America has to go back in time and collect parts to build an artifact.

Some of these parts are interconnected with a powerful force. If there’s a connection from part A to part B. Captain must collect part B before collecting A.

Sometimes a part of an artifact can be connected with itself, making it impossible to collect it.

When he collects all the parts, he can build the artifact.

Input Format

Output Format

Output “YES” if the artifact can be built, “NO” if it cannot be built.

Constraints

1 <= n <= 100,000

0 <= r <= 5000

Sample Input 0

2 1
1 0

Sample Output 0

YES