Please help me in SNGRAPH

I am geting WA for the SNGRAPH question. question link: https://www.codechef.com/SNCKPB17/problems/SNGRAPH
and here’s my solution: https://ideone.com/raYtCB

whenever we remove an edge from the spanning tree we need to add it back. removal of any other edge will not disconnect the graph. :confused: there will be some edge cases though :stuck_out_tongue:

Can you help me with a test case on which my code is failing. It will be very helpful. Thanks.

Refer this for solution: Editorial
Also refer answers to find sample tc which may fail your code. I hope this helps ! :slight_smile: