what is wrong in my approach for Snake and Graph Problem? What is your approach?

My Approach-

https://www.codechef.com/viewsolution/13967371

Please explain your appraoch.

PS-New to graph problems

Your code fails in this testcase:

    1
    11 9
    1 5  
    2 5  
    3 5  
    4 5  
    5 6  
    6 11  
    11 7  
    11 8  
    11 9
1 Like

my approach is totally wrong?

[can anyone tell , where I am wrong][1]

https://www.codechef.com/viewsolution/13937352

what is required o/p?

Can someone tell any flaw in it
[sol][1]
[1]: https://www.codechef.com/viewsolution/13972952

Please Help me.