I think the dataset for this problem is weak. I got AC without checking for cycles.
Input:
3 3
1 3
3 2
2 1
1 3 2
Correct output:
NO
But my code (
http://ideone.com/ZljGZ5 ) returns YES and it got Accepted.
Edited by author 25.07.2017 14:17 Edited by author 25.07.2017 14:18