Why is this solution of mine for SPOJ Buglife giving WA?

https://pastebin.com/AjjMVb1Q

Note: I have used disjoint set union approach.