RECHEND Mistake in my solution

I wrote a solution during the contest however it seems I am making a mistake I cannot identify. Will be glad if anyone can help.
https://www.codechef.com/viewsolution/53067078

Try this testcase:
1
5
1 3
2 1
3 5
4 4
5 2

Yours: NO
Correct: YES

1 Like

Thanks, seems there is a problem with assigning of diagonal numbers.

1 Like