Skip to content

Commit 818e437

Browse files
committed
format
1 parent 0bf23f6 commit 818e437

File tree

4 files changed

+40
-36
lines changed

4 files changed

+40
-36
lines changed

library/trees/edge_cd.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
//! handle single-edge-paths separately
2222
//! @time O(n logφ n)
2323
//! @space O(n)
24-
template <class F, class G>
25-
struct edge_cd {
24+
template<class F, class G> struct edge_cd {
2625
vector<G> adj;
2726
F f;
2827
vi siz;
29-
edge_cd(const vector<G>& adj, F f) : adj(adj), f(f), siz(sz(adj)) {
28+
edge_cd(const vector<G>& adj, F f):
29+
adj(adj), f(f), siz(sz(adj)) {
3030
dfs(0, sz(adj) - 1);
3131
}
3232
int find_cent(int v, int p, int m) {
@@ -38,7 +38,8 @@ struct edge_cd {
3838
siz[v] += siz[u];
3939
}
4040
if (p == -1) return v;
41-
return 2 * siz[v] > m ? siz[p] = m + 1 - siz[v], v : -1;
41+
return 2 * siz[v] > m ? siz[p] = m + 1 - siz[v],
42+
v : -1;
4243
}
4344
void dfs(int v, int m) {
4445
if (m < 2) return;

tests/library_checker_aizu_tests/edge_cd_asserts.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
2-
void edge_cd_asserts(const vector<vi>& adj, int cent, int split) {
2+
void edge_cd_asserts(const vector<vi>& adj, int cent,
3+
int split) {
34
assert(0 < split && split < sz(adj[cent]));
45
auto dfs = [&](auto&& self, int u, int p) -> int {
56
int siz = 1;
@@ -15,12 +16,11 @@ void edge_cd_asserts(const vector<vi>& adj, int cent, int split) {
1516
int sz_subtree = dfs(dfs, adj[cent][i], cent);
1617
assert(2 * sz_subtree <= sz_all);
1718
cnts[i < split] += sz_subtree;
18-
max_cnt[i < split] = max(max_cnt[i < split], sz_subtree);
19+
max_cnt[i < split] =
20+
max(max_cnt[i < split], sz_subtree);
1921
}
2022
assert(cnts[0] + cnts[1] + 1 == sz_all);
21-
2223
if (sz_all == 4) return;
23-
2424
// a is the number of edges in the smaller edge set
2525
// b is the number of edges in the larger edge set
2626
// so we know 1/2 <= b/(a+b)
@@ -29,12 +29,10 @@ void edge_cd_asserts(const vector<vi>& adj, int cent, int split) {
2929
assert(a <= b);
3030
return b * b <= a * (a + b);
3131
};
32-
3332
if (cnts[0] > cnts[1]) {
3433
swap(cnts[0], cnts[1]);
3534
swap(max_cnt[0], max_cnt[1]);
3635
}
37-
3836
if (!is_balanced(cnts[0], cnts[1])) {
3937
int a = max_cnt[1];
4038
int b = cnts[1] - max_cnt[1];

tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A"
1+
#define PROBLEM \
2+
"https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A"
23
#include "../template.hpp"
34
#include "../../../library/contest/random.hpp"
45
#include "../../../library/graphs/functional_graph_processor.hpp"
@@ -8,7 +9,7 @@ struct functional_graph_processor {
89
init(sz(next));
910
build(next);
1011
}
11-
template <class Graph_t>
12+
template<class Graph_t>
1213
functional_graph_processor(const Graph_t &g) {
1314
init(g.n);
1415
build(g);
@@ -100,31 +101,30 @@ struct functional_graph_processor {
100101
}
101102
int n;
102103
vector<vector<int>> cycle;
103-
vector<int> cycle_id; // id of the cycle it belongs to,
104-
// -1 if not part of one
105-
vector<int> cycle_pos; // position in its cycle, -1 if
106-
// not part of one
107-
vector<int> cycle_prev; // previous vertex in its cycle,
108-
// -1 if not part of one
109-
vector<int> component_size; // size of its weakly
110-
// connected component
111-
vector<int> root_of; // first reachable node in a cycle
112-
vector<int> depth; // distance to its root
113-
vector<vector<int>> abr; // forest of arborescences of reversed edges not
114-
// on the cycles
115-
vector<int> order; // dfs order of abr
116-
vector<int> pos; // pos in the dfs order
117-
vector<int> end; // [pos[u], end[u]) denotes the subtree
118-
vector<int> size; // size of the subtree in abr
104+
vector<int> cycle_id; // id of the cycle it belongs to,
105+
// -1 if not part of one
106+
vector<int> cycle_pos; // position in its cycle, -1 if
107+
// not part of one
108+
vector<int> cycle_prev; // previous vertex in its cycle,
109+
// -1 if not part of one
110+
vector<int> component_size; // size of its weakly
111+
// connected component
112+
vector<int> root_of; // first reachable node in a cycle
113+
vector<int> depth; // distance to its root
114+
vector<vector<int>>
115+
abr; // forest of arborescences of reversed edges not
116+
// on the cycles
117+
vector<int> order; // dfs order of abr
118+
vector<int> pos; // pos in the dfs order
119+
vector<int> end; // [pos[u], end[u]) denotes the subtree
120+
vector<int> size; // size of the subtree in abr
119121
};
120-
121122
bool equal(const basic_string<int> &a, const vi &b) {
122123
if (sz(a) != sz(b)) return 0;
123124
for (int i = 0; i < sz(a); i++)
124125
if (a[i] != b[i]) return 0;
125126
return 1;
126127
}
127-
128128
int main() {
129129
cin.tie(0)->sync_with_stdio(0);
130130
for (int num_tests = 100; num_tests--;) {
@@ -135,19 +135,23 @@ int main() {
135135
functional_graph_processor fgp(a);
136136
assert(cycle == fgp.cycle);
137137
for (int i = 0; i < n; i++) {
138-
int root = cycle[t[i].root_of.first][t[i].root_of.second];
138+
int root =
139+
cycle[t[i].root_of.first][t[i].root_of.second];
139140
assert(root == fgp.root_of[i]);
140141
assert(equal(t[i].childs, fgp.abr[i]));
141142
assert((root == i) == (fgp.cycle_id[i] != -1));
142143
if (root == i) {
143144
assert(t[i].root_of.first == fgp.cycle_id[i]);
144145
assert(t[i].root_of.second == fgp.cycle_pos[i]);
145146
int cyc_len = ssize(cycle[t[i].root_of.first]);
146-
assert(cycle[t[i].root_of.first][(t[i].root_of.second + 1) % cyc_len] ==
147-
a[i]);
147+
assert(
148+
cycle[t[i].root_of.first]
149+
[(t[i].root_of.second + 1) % cyc_len] ==
150+
a[i]);
148151
assert(fgp.cycle_prev[i] ==
149-
cycle[t[i].root_of.first]
150-
[(t[i].root_of.second - 1 + cyc_len) % cyc_len]);
152+
cycle[t[i].root_of.first]
153+
[(t[i].root_of.second - 1 + cyc_len) %
154+
cyc_len]);
151155
} else {
152156
assert(fgp.cycle_prev[i] == -1);
153157
}

tests/library_checker_aizu_tests/math/xor_basis.test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ int main() {
2626
int64_t val2 = unordered.shrink(val1);
2727
assert(val1 == val2);
2828
for (int64_t v : unordered.b)
29-
assert((bit_floor((unsigned long long)v) & val2) == 0);
29+
assert(
30+
(bit_floor((unsigned long long)v) & val2) == 0);
3031
bool inserted_unordered = unordered.insert(elem);
3132
bool inserted_ordered_ll = ordered_ll.insert(elem);
3233
bool inserted_ordered_bitset =

0 commit comments

Comments
 (0)