Skip to content

Commit 2cba688

Browse files
committed
even more nits
1 parent 0a7faa9 commit 2cba688

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

library/dsu/dsu_bipartite.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ struct dsu_bipartite {
77
vi p, is_bi, parity;
88
dsu_bipartite(int n):
99
num_sets(n), p(n, -1), is_bi(n, 1), parity(n) {}
10-
int find(int v) {
10+
int f(int v) {
1111
if (p[v] < 0) return v;
12-
int root = find(p[v]);
12+
int root = f(p[v]);
1313
parity[v] ^= parity[p[v]];
1414
return p[v] = root;
1515
}
1616
bool join(int u, int v) {
17-
int root_u = find(u), root_v = find(v);
17+
int root_u = f(u), root_v = f(v);
1818
if (root_u == root_v) {
1919
if (parity[u] == parity[v]) is_bi[root_u] = 0;
2020
return 0;
@@ -28,9 +28,6 @@ struct dsu_bipartite {
2828
p[root_u] += p[root_v], p[root_v] = root_u, num_sets--;
2929
return 1;
3030
}
31-
int size(int v) { return -p[find(v)]; }
32-
bool same_set(int u, int v) {
33-
return find(u) == find(v);
34-
}
35-
bool is_bipartite(int v) { return is_bi[find(v)]; }
31+
int size(int v) { return -p[f(v)]; }
32+
bool is_bipartite(int v) { return is_bi[f(v)]; }
3633
};

tests/library_checker_aizu_tests/dsu/dsu_bipartite.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int main() {
4242
dsu.join(u, v);
4343
adj[u].push_back(v);
4444
adj[v].push_back(u);
45-
} else cout << dsu.same_set(u, v) << '\n';
45+
} else cout << (dsu.f(u) == dsu.f(v)) << '\n';
4646
if (rnd<int>(0, 20'000) == 0) check();
4747
}
4848
check();

0 commit comments

Comments
 (0)