Question on Disjoint Set Union Find (Foxlings on Spoj)- Getting SIGSEV


I’m trying to solve this question. But constantly getting segmentation fault. Plz help!

Code : https://ideone.com/fXY4We

This is how you are counting the unused nodes: Storing the nodes used in a vector in sorted order and then finding the difference between every two consecutive nodes.

No need to do that. The number of unused nodes will be equal to N-set.size() which gives AC.
Here is the code https://pastebin.com/wPshKRRg

1 Like

Thanks man! … but why was that resulting in a SIGSEV?

I don’t know why it is giving SIGSEV. I am trying to find the error and will let you know if i find the bug.

1 Like