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 : fXY4We - Online C++0x Compiler & Debugging Tool - Ideone.com

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 #include <bits/stdc++.h>using namespace std;#define endl '\n'int arr[20000 - Pastebin.com

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