MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / union_find

Method union_find

code/data-structures/union_find.cpp:2–2  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1struct union_find {
2 vi p; union_find(int n) : p(n, -1) { }
3 int find(int x) { return p[x] < 0 ? x : p[x] = find(p[x]); }
4 bool unite(int x, int y) {
5 int xp = find(x), yp = find(y);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected