File tree Expand file tree Collapse file tree 2 files changed +20
-22
lines changed
Expand file tree Collapse file tree 2 files changed +20
-22
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments