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 | 3882 |
2 | maroonrk | 3539 |
3 | Benq | 3513 |
4 | MiracleFaFa | 3466 |
5 | ksun48 | 3462 |
6 | ecnerwala | 3446 |
7 | slime | 3428 |
8 | Um_nik | 3426 |
9 | jiangly | 3401 |
10 | greenheadstrange | 3393 |
# | User | Contrib. |
---|---|---|
1 | awoo | 192 |
2 | -is-this-fft- | 191 |
3 | Monogon | 184 |
4 | YouKn0wWho | 182 |
4 | Um_nik | 182 |
6 | antontrygubO_o | 172 |
7 | maroonrk | 169 |
8 | kostka | 165 |
9 | SecondThread | 164 |
9 | errorgorn | 164 |
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.Thx :) it works ... SOLVED !
this was from ongoing contest : https://www.hackerrank.com/contests/morgan-stanley-2015/leaderboard ..