SIGSEGV error in BLINNET

Here is the link to question : SPOJ.com - Problem BLINNET
Link to my solution : BLINNET - Replit

While submitting the solution, it’s showing sigsegv error which occurs due to invalid memory referrence but I don’t see that happening in my code. I have already tried for more than a hour to fix it but to no avail.
Can someone please help me find it?

TIA!

Why are you using const in

bool comp(const node l,const node r) {
    return l.cost < r.cost;
}

second, you are using long long int at every place which you don’t need to.

and you are using

lld root(lld nodes) {
if (parent[nodes] != nodes)
    parent[nodes] = root(parent[nodes]);
return parent[nodes];
}

which might call recursively many time itself maybe causing that error.

use only int main() instead of int main(void)

That is not the case because when I replace my edge array with vector it passed which simply signifies that comp and root function don’t have any bug!