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

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

CodeChef: Practical coding for everyone

Can someone tell any flaw in it
[sol][1]
[1]: CodeChef: Practical coding for everyone

Please Help me.

my approach is totally wrong?

what is required o/p?