diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 6f108b0f..04d539f5 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -77,7 +77,7 @@ "tests/library_checker_aizu_tests/handmade_tests/dsu.test.cpp": "2026-01-22 10:08:22 -0700", "tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2026-03-16 14:36:46 -0600", "tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2026-01-28 21:48:16 -0700", -"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2025-08-06 16:18:37 -0600", +"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2026-03-24 10:50:28 -0600", "tests/library_checker_aizu_tests/handmade_tests/hilbert_mos.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/handmade_tests/kd_bit.test.cpp": "2026-02-19 18:06:52 -0700", "tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2026-01-18 11:15:41 +0000", diff --git a/library/data_structures_[l,r)/seg_tree.hpp b/library/data_structures_[l,r)/seg_tree.hpp index 62c023a2..516d99af 100644 --- a/library/data_structures_[l,r)/seg_tree.hpp +++ b/library/data_structures_[l,r)/seg_tree.hpp @@ -7,10 +7,12 @@ //! }); //! tree st(n, LLONG_MAX, ranges::min); //! st.max_right(l, r, [&](int m, ll value) { +//! // l < m <= r //! // value = op(a[l], a[l+1], ..., a[m-1]) //! return value <= x; //! }); //! st.min_left(l, r, [&](int m, ll value) { +//! // l <= m < r //! // value = op(a[m], ..., a[r-2], a[r-1]) //! return value <= x; //! }); diff --git a/library/data_structures_[l,r]/seg_tree.hpp b/library/data_structures_[l,r]/seg_tree.hpp index af078913..5b3cdfd2 100644 --- a/library/data_structures_[l,r]/seg_tree.hpp +++ b/library/data_structures_[l,r]/seg_tree.hpp @@ -6,10 +6,12 @@ //! }); //! tree st(n, LLONG_MAX, ranges::min); //! st.max_right(l, r, [&](int m, ll value) { +//! // l <= m <= r //! // value = op(a[l], a[l+1], ..., a[m]) //! return value <= x; //! }); //! st.min_left(l, r, [&](int m, ll value) { +//! // l <= m <= r //! // value = op(a[m], ..., a[r-1], a[r]) //! return value <= x; //! }); diff --git a/library/graphs/uncommon/functional_graph_processor.hpp b/library/graphs/uncommon/functional_graph_processor.hpp index db659e0d..67ad0929 100644 --- a/library/graphs/uncommon/functional_graph_processor.hpp +++ b/library/graphs/uncommon/functional_graph_processor.hpp @@ -11,25 +11,25 @@ //! t[v].childs = forest of reversed edges not in cycles //! @time O(n) //! @space O(n) -struct func_graph { - vector root_of; - vector cycle, childs; - func_graph(const vi& a): root_of(sz(a)), childs(sz(a)) { - vi vis(sz(a)); - rep(i, 0, sz(a)) if (!vis[i]) { - int u = i; - for (; !vis[u]; u = a[u]) vis[u] = 1; - if (vis[u] == 1) - for (cycle.emplace_back(); vis[u] == 1; u = a[u]) { - root_of[u] = {sz(cycle) - 1, sz(cycle.back())}; - cycle.back().push_back(u); - vis[u] = 2; - } - for (int v = i; vis[v] == 1; v = a[v]) { - root_of[v] = root_of[u]; - childs[a[v]].push_back(v); - vis[v] = 2; +auto func_graph(const vi& a) { + int n = sz(a); + vector root_of(n); + vector cycle, childs(n); + vi vis(n); + rep(i, 0, n) if (!vis[i]) { + int u = i; + for (; !vis[u]; u = a[u]) vis[u] = 1; + if (vis[u] == 1) + for (cycle.emplace_back(); vis[u] == 1; u = a[u]) { + root_of[u] = {sz(cycle) - 1, sz(cycle.back())}; + cycle.back().push_back(u); + vis[u] = 2; } + for (int v = i; vis[v] == 1; v = a[v]) { + root_of[v] = root_of[u]; + childs[a[v]].push_back(v); + vis[v] = 2; } } -}; + return tuple{root_of, cycle, childs}; +}