Skip to content

Commit c665915

Browse files
authored
Update dsu var (#166)
* change * fix
1 parent 1979621 commit c665915

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#pragma once
22
// NOLINTNEXTLINE(readability-identifier-naming)
33
struct DSU {
4-
vi e;
5-
DSU(int n): e(n, -1) {}
6-
int size(int x) { return -e[go(x)]; }
7-
int go(int x) { return e[x] < 0 ? x : e[x] = go(e[x]); }
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]); }
88
bool join(int a, int b) {
99
if ((a = go(a)) == (b = go(b))) return 0;
10-
if (e[a] > e[b]) swap(a, b);
11-
return e[a] += e[b], e[b] = a, 1;
10+
if (p[a] > p[b]) swap(a, b);
11+
return p[a] += p[b], p[b] = a, 1;
1212
}
1313
};

tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int main() {
2727
auto [u, v] = eds[order[it]];
2828
u = dsu.go(u);
2929
v = dsu.go(v);
30-
if (dsu.e[u] > dsu.e[v]) swap(u, v);
30+
if (dsu.p[u] > dsu.p[v]) swap(u, v);
3131
if (u != v) {
3232
sum = (sum + 1LL * xs[u] * xs[v]) % mod;
3333
xs[u] = (xs[u] + xs[v]) % mod;

0 commit comments

Comments
 (0)