Update trees/quick_union.cc
Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
parent
9a8c1277fb
commit
a053db4b9b
|
@ -13,6 +13,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void merge(size_t i, size_t j) {
|
void merge(size_t i, size_t j) {
|
||||||
|
if (connected(i, j)) return;
|
||||||
sz[query(j)] += sz[query(i)];
|
sz[query(j)] += sz[query(i)];
|
||||||
c[query(i)] = query(j);
|
c[query(i)] = query(j);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue