Set 104Question 74

Arif's Dependency Loop Check

HardWritten in CMust finish in 3 seconds

Arif is validating task dependencies at a university club and needs to know if there's a circular dependency.

What your program reads

Line1: N M. Next M lines: u v (u depends on v).

What your program prints

"YES" if a cycle exists, else "NO".

Limits

1 ≤ N ≤ 10^5

Example input

3 3
1 2
2 3
3 1

Expected output

YES
main.c

Your work is saved in this browser as you type.

Loading editor…
Input for Run

Run tries your code on the input above and shows what it prints. Submit checks your output against every test, including hidden ones.

Shortcut: Ctrl + Enter sends it to the judge.

Arif's Dependency Loop Check · DIU ContestHub