Please give me test case which fails on below code for Spoj - Bugs’ Life (BUGLIFE). Every test case passed , still WA.
https://pastebin.com/AjjMVb1Q
Have you tried these?
I have got this problem accepted through BFS , was trying Disjoint Set Union approach now. The SPOJ toolkit gives different result than my accepted answer (BFS one) for this problem , so it’s not trustworthy.