I'm trying to solve a problem using Union Find, for storing Connected Components of a graph, and a Multiset for ordering the Components' Weights ... but i'm getting "SIGSECV ( Abort Called ) "... here is my code Link
# | User | Rating |
---|---|---|
1 | tourist | 3856 |
2 | jiangly | 3747 |
3 | orzdevinwang | 3706 |
4 | jqdai0815 | 3682 |
5 | ksun48 | 3591 |
6 | gamegame | 3477 |
7 | Benq | 3468 |
8 | Radewoosh | 3462 |
9 | ecnerwala | 3451 |
10 | heuristica | 3431 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | -is-this-fft- | 162 |
3 | Dominater069 | 160 |
4 | Um_nik | 158 |
4 | atcoder_official | 158 |
6 | Qingyu | 156 |
7 | djm03178 | 152 |
7 | adamant | 152 |
9 | luogu_official | 151 |
10 | awoo | 147 |
I'm trying to solve a problem using Union Find, for storing Connected Components of a graph, and a Multiset for ordering the Components' Weights ... but i'm getting "SIGSECV ( Abort Called ) "... here is my code Link
Name |
---|
Line 18 should be
Father[f1] = Father[f2];
.The reason you get a runtime error is as follows: Let's say
f1
is different froma
. Since you only change the parent pointer ofa
, the parent pointer off1
still points tof1
. However, the weight off1
is removed from the multiset. So if you call the merge function again withf1
, the program will try to eraseWeight[f1]
from the multiset. If the weight is no longer present though,Order.find(Weight[f1])
returnsOrder.end()
, and callingerase
on that produces a runtime error.this was from ongoing contest : https://www.hackerrank.com/contests/morgan-stanley-2015/leaderboard ..