We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7714df5 commit c1efed1Copy full SHA for c1efed1
library/data_structures/dsu/dsu.hpp
@@ -3,10 +3,10 @@
3
struct DSU {
4
vi p;
5
DSU(int n): p(n, -1) {}
6
- int size(int x) { return -p[go(x)]; }
7
- int go(int x) { return p[x] < 0 ? x : p[x] = go(p[x]); }
+ int size(int x) { return -p[f(x)]; }
+ int f(int x) { return p[x] < 0 ? x : p[x] = f(p[x]); }
8
bool join(int a, int b) {
9
- if ((a = go(a)) == (b = go(b))) return 0;
+ if ((a = f(a)) == (b = f(b))) return 0;
10
if (p[a] > p[b]) swap(a, b);
11
return p[a] += p[b], p[b] = a, 1;
12
}
0 commit comments