Skip to content

Commit 0c610d9

Browse files
lrvideckisweb-flow
andauthored
Golf (#145)
* remove some parens * [auto-verifier] verify commit 2bdc0a0 * more golf * [auto-verifier] verify commit 9c932ef --------- Co-authored-by: GitHub <noreply@github.com>
1 parent 862d4f8 commit 0c610d9

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

.verify-helper/timestamps.remote.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-12-14 19:50:29 -0600",
7272
"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2025-04-27 21:47:37 -0600",
7373
"tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-12-14 19:50:29 -0600",
74-
"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2025-05-31 11:16:27 -0600",
74+
"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2025-07-08 19:20:24 -0600",
7575
"tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2025-02-10 23:30:47 -0700",
7676
"tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2024-12-14 19:50:29 -0600",
7777
"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2025-02-11 13:53:30 -0700",

library/graphs/functional_graph_processor.hpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,27 @@ struct func_graph {
1616
vector<basic_string<int>> cycle, childs;
1717
func_graph(const vi& a): root_of(sz(a)), childs(sz(a)) {
1818
vi state(sz(a));
19-
rep(i, 0, sz(a)) {
20-
if (state[i] == 0) {
21-
int u = i;
22-
while (state[u] == 0) {
23-
state[u] = 1;
19+
rep(i, 0, sz(a)) if (!state[i]) {
20+
int u = i;
21+
while (!state[u]) {
22+
state[u] = 1;
23+
u = a[u];
24+
}
25+
if (state[u] == 1) {
26+
cycle.emplace_back();
27+
while (state[u] == 1) {
28+
root_of[u] = {sz(cycle) - 1, sz(cycle.back())};
29+
cycle.back() += u;
30+
state[u] = 2;
2431
u = a[u];
2532
}
26-
if (state[u] == 1) {
27-
cycle.emplace_back();
28-
while (state[u] == 1) {
29-
root_of[u] = {sz(cycle) - 1, sz(cycle.back())};
30-
cycle.back() += u;
31-
state[u] = 2;
32-
u = a[u];
33-
}
34-
}
35-
int v = i;
36-
while (state[v] == 1) {
37-
root_of[v] = root_of[u];
38-
childs[a[v]] += v;
39-
state[v] = 2;
40-
v = a[v];
41-
}
33+
}
34+
int v = i;
35+
while (state[v] == 1) {
36+
root_of[v] = root_of[u];
37+
childs[a[v]] += v;
38+
state[v] = 2;
39+
v = a[v];
4240
}
4341
}
4442
}

0 commit comments

Comments
 (0)