From 87352830169b28f9e63bebbb9228d03b702387fd Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 09:32:13 -0700 Subject: [PATCH 01/12] use c++20 ranges where shorter --- .../uncommon/priority_queue_of_updates.hpp | 2 +- library/graphs/mst.hpp | 5 ++--- library/strings/suffix_array/find/find_string_bs_fast.hpp | 2 +- library/strings/wildcard_pattern_matching.hpp | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp b/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp index 7796a03d..f0eab5c0 100644 --- a/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp +++ b/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp @@ -43,7 +43,7 @@ template struct pq_updates { remove_if(idx + all(upd_st), [&](auto& curr) { return curr.second->first >= lowest_pri; }); - reverse_copy(all(extra), it); + ranges::reverse_copy(extra, it); rep(i, idx, sz(upd_st)) ds.undo(); upd_st.pop_back(); mp.erase(prev(end(mp))); diff --git a/library/graphs/mst.hpp b/library/graphs/mst.hpp index d8261dec..0e6ea834 100644 --- a/library/graphs/mst.hpp +++ b/library/graphs/mst.hpp @@ -11,9 +11,8 @@ pair mst(const vector>& w_eds, int n) { vi order(sz(w_eds)); iota(all(order), 0); - ranges::sort(order, [&](int i, int j) { - return w_eds[i][2] < w_eds[j][2]; - }); + ranges::sort(order, {}, + [&](int i) { return w_eds[i][2]; }); DSU dsu(n); vi ids; ll cost = 0; diff --git a/library/strings/suffix_array/find/find_string_bs_fast.hpp b/library/strings/suffix_array/find/find_string_bs_fast.hpp index 86014517..f6d09d33 100644 --- a/library/strings/suffix_array/find/find_string_bs_fast.hpp +++ b/library/strings/suffix_array/find/find_string_bs_fast.hpp @@ -16,7 +16,7 @@ match find_str_fast(const T& t) { return lexicographical_compare(it_s, end(s), it_t, end(t)); }; - int sa_le = lower_bound(all(sa), 0, cmp) - begin(sa), + int sa_le = ranges::lower_bound(sa, 0, cmp) - begin(sa), sa_ri = sa_le; if (s_len == sz(t)) sa_ri = lower_bound(sa_le + all(sa), 0, diff --git a/library/strings/wildcard_pattern_matching.hpp b/library/strings/wildcard_pattern_matching.hpp index fe2c531a..c30d91cf 100644 --- a/library/strings/wildcard_pattern_matching.hpp +++ b/library/strings/wildcard_pattern_matching.hpp @@ -25,7 +25,7 @@ vector wildcard_pattern_matching(const vl& s, int n = sz(s), m = sz(t); auto s_pws = make_powers(s); auto t_pws = make_powers(t); - for (auto& t_pw : t_pws) reverse(all(t_pw)); + for (auto& t_pw : t_pws) ranges::reverse(t_pw); vector res(3); rep(pw_hay, 0, 3) res[pw_hay] = conv(s_pws[pw_hay], t_pws[2 - pw_hay]); From ebf5f310c54cd730254be27d3d25bffb86554ea5 Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 6 Jul 2026 16:50:39 +0000 Subject: [PATCH 02/12] [auto-verifier] verify commit 87352830169b28f9e63bebbb9228d03b702387fd --- .verify-helper/timestamps.remote.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 07d0e076..521d1452 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -33,7 +33,7 @@ "tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2026-05-24 23:00:07 -0500", "tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2026-04-26 11:38:07 -0600", "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2026-07-06 09:32:13 -0700", "tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2026-05-24 23:00:07 -0500", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2026-05-24 23:00:07 -0500", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2026-01-18 11:15:41 +0000", @@ -69,7 +69,7 @@ "tests/library_checker_aizu_tests/graphs/euler_walk_undirected.test.cpp": "2026-04-12 16:21:27 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2026-05-01 11:34:51 -0600", "tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2026-05-01 11:34:51 -0600", -"tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2026-01-22 10:08:22 -0700", +"tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2026-07-06 09:32:13 -0700", "tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2026-04-12 16:21:27 -0600", "tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2026-04-12 16:21:27 -0600", "tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2026-04-12 16:21:27 -0600", @@ -89,7 +89,7 @@ "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2026-04-26 11:38:07 -0600", "tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2026-05-24 23:00:07 -0500", "tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2026-05-24 23:00:07 -0500", -"tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2026-04-26 11:38:07 -0600", +"tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2026-07-06 09:32:13 -0700", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2026-04-26 11:38:07 -0600", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2026-04-26 11:38:07 -0600", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp": "2026-04-26 11:38:07 -0600", @@ -117,21 +117,21 @@ "tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2026-05-24 23:00:07 -0500", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2025-08-05 19:19:23 -0600", "tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2026-04-26 11:38:07 -0600", +"tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2026-07-06 09:32:13 -0700", +"tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2026-07-06 09:32:13 -0700", "tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2025-08-05 19:19:23 -0600", "tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2026-04-06 12:17:32 -0600", "tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2026-04-26 11:38:07 -0600", "tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2026-04-26 11:38:07 -0600", +"tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2026-07-06 09:32:13 -0700", "tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2025-08-05 19:19:23 -0600", -"tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2026-05-24 23:00:07 -0500", +"tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2026-07-06 09:32:13 -0700", +"tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2026-07-06 09:32:13 -0700", +"tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2026-07-06 09:32:13 -0700", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2026-07-06 09:32:13 -0700", "tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2026-04-12 06:15:25 -0600", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2026-01-17 12:38:18 -0700", -"tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2026-04-26 11:38:07 -0600", +"tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2026-07-06 09:32:13 -0700", "tests/library_checker_aizu_tests/trees/cd_count_paths_per_length.test.cpp": "2026-04-26 21:56:36 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2026-04-27 08:17:20 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2026-04-27 08:17:20 -0600", From 53a7fc4c6049a5b864cc8b3e538baddb249cf453 Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 10:14:01 -0700 Subject: [PATCH 03/12] use c++20 ranges and views in remaining full-range spots --- library/data_structures_[l,r)/uncommon/deque_op.hpp | 4 ++-- library/math/matrix_related/solve_linear_mod.hpp | 4 ++-- library/trees/extra_members/virtual_tree.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/data_structures_[l,r)/uncommon/deque_op.hpp b/library/data_structures_[l,r)/uncommon/deque_op.hpp index 43d17176..7347a067 100644 --- a/library/data_structures_[l,r)/uncommon/deque_op.hpp +++ b/library/data_structures_[l,r)/uncommon/deque_op.hpp @@ -31,7 +31,7 @@ template struct deq { void pop_back() { if (empty(r)) { vector a(sz(l)); - transform(all(l), rbegin(a), + ranges::transform(l, rbegin(a), [](dt& x) { return x[0]; }); rebuild(a, sz(a) / 2); } @@ -44,7 +44,7 @@ template struct deq { void pop_front() { if (empty(l)) { vector a(sz(r)); - transform(all(r), begin(a), + ranges::transform(r, begin(a), [](dt& x) { return x[0]; }); rebuild(a, (sz(a) + 1) / 2); } diff --git a/library/math/matrix_related/solve_linear_mod.hpp b/library/math/matrix_related/solve_linear_mod.hpp index 55b79be8..b82855ab 100644 --- a/library/math/matrix_related/solve_linear_mod.hpp +++ b/library/math/matrix_related/solve_linear_mod.hpp @@ -17,12 +17,12 @@ struct solve_linear_mod { int n = sz(mat), m = sz(mat[0]); rep(i, 0, n) mat[i].push_back(rhs[i]); tie(rank, det) = row_reduce(mat, m); - if (any_of(rank + all(mat), + if (ranges::any_of(mat | views::drop(rank), [](vi& v) { return v.back(); })) return; sol.resize(m); int j = 0; - for_each(begin(mat), begin(mat) + rank, [&](vi& v) { + ranges::for_each(mat | views::take(rank), [&](vi& v) { while (!v[j]) j++; sol[j] = v.back(); }); diff --git a/library/trees/extra_members/virtual_tree.hpp b/library/trees/extra_members/virtual_tree.hpp index 2526dc0e..674cd432 100644 --- a/library/trees/extra_members/virtual_tree.hpp +++ b/library/trees/extra_members/virtual_tree.hpp @@ -16,7 +16,7 @@ array compress_tree(vi subset) { rep(i, 1, len) subset.push_back(lca(subset[i - 1], subset[i])); ranges::sort(subset, {}, proj); - subset.erase(unique(all(subset)), end(subset)); + subset.erase(begin(ranges::unique(subset)), end(subset)); return { mono_st(subset, [&](int u, int v) { return in_subtree(u, v); }), From bbed1a125070f46a270d1f97c7647e045e50eebb Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 6 Jul 2026 17:31:49 +0000 Subject: [PATCH 04/12] [auto-verifier] verify commit 53a7fc4c6049a5b864cc8b3e538baddb249cf453 --- .verify-helper/timestamps.remote.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 521d1452..5194eb49 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -12,10 +12,10 @@ "tests/library_checker_aizu_tests/data_structures/bit_rupq.test.cpp": "2026-04-06 12:17:32 -0600", "tests/library_checker_aizu_tests/data_structures/bit_rurq.test.cpp": "2026-04-06 12:17:32 -0600", "tests/library_checker_aizu_tests/data_structures/bit_walk.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/data_structures/deque.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/deque_index.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/deque_op.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/deque_sliding_window.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/deque.test.cpp": "2026-07-06 10:14:01 -0700", +"tests/library_checker_aizu_tests/data_structures/deque_index.test.cpp": "2026-07-06 10:14:01 -0700", +"tests/library_checker_aizu_tests/data_structures/deque_op.test.cpp": "2026-07-06 10:14:01 -0700", +"tests/library_checker_aizu_tests/data_structures/deque_sliding_window.test.cpp": "2026-07-06 10:14:01 -0700", "tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc.test.cpp": "2026-01-18 11:15:41 +0000", "tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc_lines.test.cpp": "2026-01-18 11:15:41 +0000", "tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc_sum.test.cpp": "2026-01-18 11:15:41 +0000", @@ -74,7 +74,7 @@ "tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2026-04-12 16:21:27 -0600", "tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2026-04-12 16:21:27 -0600", "tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2026-04-12 16:21:27 -0600", -"tests/library_checker_aizu_tests/handmade_tests/count_paths.test.cpp": "2026-04-27 08:17:20 -0600", +"tests/library_checker_aizu_tests/handmade_tests/count_paths.test.cpp": "2026-07-06 10:14:01 -0700", "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-04-27 08:17:20 -0600", "tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2026-01-28 21:48:16 -0700", @@ -107,7 +107,7 @@ "tests/library_checker_aizu_tests/math/num_subsequences.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/partitions.test.cpp": "2025-08-28 13:19:16 -0600", "tests/library_checker_aizu_tests/math/prime_sieve.test.cpp": "2024-11-22 11:54:52 -0600", -"tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2026-04-12 10:51:29 -0600", +"tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2026-07-06 10:14:01 -0700", "tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2026-04-26 11:38:07 -0600", @@ -142,12 +142,12 @@ "tests/library_checker_aizu_tests/trees/hld_lib_checker_path.test.cpp": "2026-04-12 16:21:27 -0600", "tests/library_checker_aizu_tests/trees/hld_lib_checker_subtree_edges.test.cpp": "2026-04-12 16:21:27 -0600", "tests/library_checker_aizu_tests/trees/hld_lib_checker_subtree_nodes.test.cpp": "2026-04-12 16:21:27 -0600", -"tests/library_checker_aizu_tests/trees/kth_path_hagerup.test.cpp": "2026-06-27 13:02:40 -0500", +"tests/library_checker_aizu_tests/trees/kth_path_hagerup.test.cpp": "2026-07-06 10:14:01 -0700", "tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2026-06-27 13:02:40 -0500", "tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2026-06-27 18:29:52 -0500", -"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2026-04-26 11:38:07 -0600", -"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2026-04-26 11:38:07 -0600", +"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2026-07-06 10:14:01 -0700", +"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2026-07-06 10:14:01 -0700", +"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2026-07-06 10:14:01 -0700", "tests/library_checker_aizu_tests/trees/shallowest_aizu_tree_height.test.cpp": "2026-04-12 16:21:27 -0600", "tests/library_checker_aizu_tests/trees/shallowest_lib_checker_tree_path_composite.test.cpp": "2026-04-26 11:38:07 -0600", "tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2026-04-12 16:21:27 -0600" From 77bba36536c353746920a19eec734e1adfd44786 Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 11:17:45 -0700 Subject: [PATCH 05/12] use c++20 idioms in doc examples: nullptr over NULL, ll() over (ll) cast --- library/data_structures_[l,r)/rmq.hpp | 2 +- library/data_structures_[l,r]/rmq.hpp | 2 +- library/flow/hungarian.hpp | 2 +- library/strings/manacher/longest_palindrome_query.hpp | 2 +- library/trees/lca_rmq.hpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/data_structures_[l,r)/rmq.hpp b/library/data_structures_[l,r)/rmq.hpp index ffd78c72..14a8efb8 100644 --- a/library/data_structures_[l,r)/rmq.hpp +++ b/library/data_structures_[l,r)/rmq.hpp @@ -5,7 +5,7 @@ //! return min(x, y); //! }); //! vector>> -//! rmqs(3, {{}, NULL}); +//! rmqs(3, {{}, nullptr}); //! rmqs[1] = {a, ranges::min}; //! @endcode //! @time O(nlogn + q) diff --git a/library/data_structures_[l,r]/rmq.hpp b/library/data_structures_[l,r]/rmq.hpp index b7d58b9f..c5291f62 100644 --- a/library/data_structures_[l,r]/rmq.hpp +++ b/library/data_structures_[l,r]/rmq.hpp @@ -5,7 +5,7 @@ //! return min(x, y); //! }); //! vector>> -//! rmqs(3, {{}, NULL}); +//! rmqs(3, {{}, nullptr}); //! rmqs[1] = {a, ranges::min}; //! @endcode //! @time O(nlogn + q) diff --git a/library/flow/hungarian.hpp b/library/flow/hungarian.hpp index c2f47486..954b0f44 100644 --- a/library/flow/hungarian.hpp +++ b/library/flow/hungarian.hpp @@ -1,7 +1,7 @@ #pragma once //! https://e-maxx.ru/algo/assignment_hungary //! @code -//! vector cost(n+1,vector(m+1,(ll)0)); +//! vector cost(n+1,vector(m+1,ll(0))); //! auto [min_weight, l_to_r] = hungarian(cost); //! @endcode //! cost[i][j] = edge weight, 1<=i<=n<=m; 1<=j<=m diff --git a/library/strings/manacher/longest_palindrome_query.hpp b/library/strings/manacher/longest_palindrome_query.hpp index 499619d4..5d2592d3 100644 --- a/library/strings/manacher/longest_palindrome_query.hpp +++ b/library/strings/manacher/longest_palindrome_query.hpp @@ -5,7 +5,7 @@ //! substring struct longest_pal_query { vi man; - RMQ> rmq = {{}, NULL}; + RMQ> rmq = {{}, nullptr}; //! @param s string/vector //! @time O(n log n) //! @space O(n log n) for rmq, everything else is O(n) diff --git a/library/trees/lca_rmq.hpp b/library/trees/lca_rmq.hpp index ea3bc660..8866d933 100644 --- a/library/trees/lca_rmq.hpp +++ b/library/trees/lca_rmq.hpp @@ -12,7 +12,7 @@ struct LCA { int n; vi tin, siz, d, p; - RMQ> rmq = {{}, NULL}; + RMQ> rmq = {{}, nullptr}; LCA(const auto& g): n(sz(g)), tin(n), siz(n, 1), d(n), p(n) { vi order; From 7bfb345722c7d211c2b254532f4cdcd1d2b2659b Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 11:24:52 -0700 Subject: [PATCH 06/12] Revert "use c++20 idioms in doc examples: nullptr over NULL, ll() over (ll) cast" This reverts commit 77bba36536c353746920a19eec734e1adfd44786. --- library/data_structures_[l,r)/rmq.hpp | 2 +- library/data_structures_[l,r]/rmq.hpp | 2 +- library/flow/hungarian.hpp | 2 +- library/strings/manacher/longest_palindrome_query.hpp | 2 +- library/trees/lca_rmq.hpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/data_structures_[l,r)/rmq.hpp b/library/data_structures_[l,r)/rmq.hpp index 14a8efb8..ffd78c72 100644 --- a/library/data_structures_[l,r)/rmq.hpp +++ b/library/data_structures_[l,r)/rmq.hpp @@ -5,7 +5,7 @@ //! return min(x, y); //! }); //! vector>> -//! rmqs(3, {{}, nullptr}); +//! rmqs(3, {{}, NULL}); //! rmqs[1] = {a, ranges::min}; //! @endcode //! @time O(nlogn + q) diff --git a/library/data_structures_[l,r]/rmq.hpp b/library/data_structures_[l,r]/rmq.hpp index c5291f62..b7d58b9f 100644 --- a/library/data_structures_[l,r]/rmq.hpp +++ b/library/data_structures_[l,r]/rmq.hpp @@ -5,7 +5,7 @@ //! return min(x, y); //! }); //! vector>> -//! rmqs(3, {{}, nullptr}); +//! rmqs(3, {{}, NULL}); //! rmqs[1] = {a, ranges::min}; //! @endcode //! @time O(nlogn + q) diff --git a/library/flow/hungarian.hpp b/library/flow/hungarian.hpp index 954b0f44..c2f47486 100644 --- a/library/flow/hungarian.hpp +++ b/library/flow/hungarian.hpp @@ -1,7 +1,7 @@ #pragma once //! https://e-maxx.ru/algo/assignment_hungary //! @code -//! vector cost(n+1,vector(m+1,ll(0))); +//! vector cost(n+1,vector(m+1,(ll)0)); //! auto [min_weight, l_to_r] = hungarian(cost); //! @endcode //! cost[i][j] = edge weight, 1<=i<=n<=m; 1<=j<=m diff --git a/library/strings/manacher/longest_palindrome_query.hpp b/library/strings/manacher/longest_palindrome_query.hpp index 5d2592d3..499619d4 100644 --- a/library/strings/manacher/longest_palindrome_query.hpp +++ b/library/strings/manacher/longest_palindrome_query.hpp @@ -5,7 +5,7 @@ //! substring struct longest_pal_query { vi man; - RMQ> rmq = {{}, nullptr}; + RMQ> rmq = {{}, NULL}; //! @param s string/vector //! @time O(n log n) //! @space O(n log n) for rmq, everything else is O(n) diff --git a/library/trees/lca_rmq.hpp b/library/trees/lca_rmq.hpp index 8866d933..ea3bc660 100644 --- a/library/trees/lca_rmq.hpp +++ b/library/trees/lca_rmq.hpp @@ -12,7 +12,7 @@ struct LCA { int n; vi tin, siz, d, p; - RMQ> rmq = {{}, nullptr}; + RMQ> rmq = {{}, NULL}; LCA(const auto& g): n(sz(g)), tin(n), siz(n, 1), d(n), p(n) { vi order; From 5062d4fe9c07c85ec68e41700b9745da77adf4af Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 11:25:30 -0700 Subject: [PATCH 07/12] use functional cast in hungarian doc example --- library/flow/hungarian.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/flow/hungarian.hpp b/library/flow/hungarian.hpp index c2f47486..954b0f44 100644 --- a/library/flow/hungarian.hpp +++ b/library/flow/hungarian.hpp @@ -1,7 +1,7 @@ #pragma once //! https://e-maxx.ru/algo/assignment_hungary //! @code -//! vector cost(n+1,vector(m+1,(ll)0)); +//! vector cost(n+1,vector(m+1,ll(0))); //! auto [min_weight, l_to_r] = hungarian(cost); //! @endcode //! cost[i][j] = edge weight, 1<=i<=n<=m; 1<=j<=m From 80a247aa399b351d3b7e619a21242d037c1e35ad Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 11:57:03 -0700 Subject: [PATCH 08/12] revert non-strict-win ranges conversions (views::drop/take, ranges::unique) --- library/math/matrix_related/solve_linear_mod.hpp | 4 ++-- library/trees/extra_members/virtual_tree.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/math/matrix_related/solve_linear_mod.hpp b/library/math/matrix_related/solve_linear_mod.hpp index b82855ab..55b79be8 100644 --- a/library/math/matrix_related/solve_linear_mod.hpp +++ b/library/math/matrix_related/solve_linear_mod.hpp @@ -17,12 +17,12 @@ struct solve_linear_mod { int n = sz(mat), m = sz(mat[0]); rep(i, 0, n) mat[i].push_back(rhs[i]); tie(rank, det) = row_reduce(mat, m); - if (ranges::any_of(mat | views::drop(rank), + if (any_of(rank + all(mat), [](vi& v) { return v.back(); })) return; sol.resize(m); int j = 0; - ranges::for_each(mat | views::take(rank), [&](vi& v) { + for_each(begin(mat), begin(mat) + rank, [&](vi& v) { while (!v[j]) j++; sol[j] = v.back(); }); diff --git a/library/trees/extra_members/virtual_tree.hpp b/library/trees/extra_members/virtual_tree.hpp index 674cd432..2526dc0e 100644 --- a/library/trees/extra_members/virtual_tree.hpp +++ b/library/trees/extra_members/virtual_tree.hpp @@ -16,7 +16,7 @@ array compress_tree(vi subset) { rep(i, 1, len) subset.push_back(lca(subset[i - 1], subset[i])); ranges::sort(subset, {}, proj); - subset.erase(begin(ranges::unique(subset)), end(subset)); + subset.erase(unique(all(subset)), end(subset)); return { mono_st(subset, [&](int u, int v) { return in_subtree(u, v); }), From 6e3bb1c4e46ef9befe0ea58b0cdd8e64f36c40c0 Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 12:04:00 -0700 Subject: [PATCH 09/12] Revert "revert non-strict-win ranges conversions (views::drop/take, ranges::unique)" This reverts commit 80a247aa399b351d3b7e619a21242d037c1e35ad. --- library/math/matrix_related/solve_linear_mod.hpp | 4 ++-- library/trees/extra_members/virtual_tree.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/math/matrix_related/solve_linear_mod.hpp b/library/math/matrix_related/solve_linear_mod.hpp index 55b79be8..b82855ab 100644 --- a/library/math/matrix_related/solve_linear_mod.hpp +++ b/library/math/matrix_related/solve_linear_mod.hpp @@ -17,12 +17,12 @@ struct solve_linear_mod { int n = sz(mat), m = sz(mat[0]); rep(i, 0, n) mat[i].push_back(rhs[i]); tie(rank, det) = row_reduce(mat, m); - if (any_of(rank + all(mat), + if (ranges::any_of(mat | views::drop(rank), [](vi& v) { return v.back(); })) return; sol.resize(m); int j = 0; - for_each(begin(mat), begin(mat) + rank, [&](vi& v) { + ranges::for_each(mat | views::take(rank), [&](vi& v) { while (!v[j]) j++; sol[j] = v.back(); }); diff --git a/library/trees/extra_members/virtual_tree.hpp b/library/trees/extra_members/virtual_tree.hpp index 2526dc0e..674cd432 100644 --- a/library/trees/extra_members/virtual_tree.hpp +++ b/library/trees/extra_members/virtual_tree.hpp @@ -16,7 +16,7 @@ array compress_tree(vi subset) { rep(i, 1, len) subset.push_back(lca(subset[i - 1], subset[i])); ranges::sort(subset, {}, proj); - subset.erase(unique(all(subset)), end(subset)); + subset.erase(begin(ranges::unique(subset)), end(subset)); return { mono_st(subset, [&](int u, int v) { return in_subtree(u, v); }), From 65e3ff77442d757b2feed44b821926efa1a5da47 Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 12:18:49 -0700 Subject: [PATCH 10/12] use ranges/views and consistently: offset ranges via views::drop/take, __lg -> bit_width/bit_floor --- library/data_structures_[l,r)/rmq.hpp | 2 +- library/data_structures_[l,r)/seg_tree_midpoint.hpp | 2 +- .../data_structures_[l,r)/seg_tree_uncommon/max_right.hpp | 3 ++- .../data_structures_[l,r)/seg_tree_uncommon/min_left.hpp | 3 ++- library/data_structures_[l,r)/uncommon/deque_op.hpp | 7 ++++--- .../uncommon/priority_queue_of_updates.hpp | 7 ++++--- library/data_structures_[l,r]/disjoint_rmq.hpp | 2 +- library/data_structures_[l,r]/rmq.hpp | 2 +- library/data_structures_[l,r]/seg_tree.hpp | 3 ++- .../data_structures_[l,r]/seg_tree_uncommon/max_right.hpp | 3 ++- .../data_structures_[l,r]/seg_tree_uncommon/min_left.hpp | 3 ++- library/dsu/range_parallel_dsu.hpp | 2 +- .../offline_incremental_scc.hpp | 7 ++++--- library/strings/suffix_array/find/find_string_bs_fast.hpp | 6 +++--- library/strings/suffix_array/find/find_substring.hpp | 7 ++++--- library/trees/edge_cd.hpp | 4 ++-- library/trees/uncommon/ladder_decomposition.hpp | 2 +- library/trees/uncommon/linear_kth_par.hpp | 3 ++- 18 files changed, 39 insertions(+), 29 deletions(-) diff --git a/library/data_structures_[l,r)/rmq.hpp b/library/data_structures_[l,r)/rmq.hpp index ffd78c72..5df5850b 100644 --- a/library/data_structures_[l,r)/rmq.hpp +++ b/library/data_structures_[l,r)/rmq.hpp @@ -23,7 +23,7 @@ template struct RMQ { } T query(int l, int r) { assert(l < r); - int lg = __lg(r - l); + int lg = bit_width(r - l + 0u) - 1; return op(dp[lg][l], dp[lg][r - (1 << lg)]); } }; diff --git a/library/data_structures_[l,r)/seg_tree_midpoint.hpp b/library/data_structures_[l,r)/seg_tree_midpoint.hpp index 933aaf02..41527639 100644 --- a/library/data_structures_[l,r)/seg_tree_midpoint.hpp +++ b/library/data_structures_[l,r)/seg_tree_midpoint.hpp @@ -1,6 +1,6 @@ #pragma once //! https://codeforces.com/blog/entry/112755 int split(int tl, int tr) { - int pw2 = 1 << __lg(tr - tl); + int pw2 = bit_floor(tr - tl + 0u); return min(tl + pw2, tr - pw2 / 2); } diff --git a/library/data_structures_[l,r)/seg_tree_uncommon/max_right.hpp b/library/data_structures_[l,r)/seg_tree_uncommon/max_right.hpp index 4ac12cc4..91af8fa5 100644 --- a/library/data_structures_[l,r)/seg_tree_uncommon/max_right.hpp +++ b/library/data_structures_[l,r)/seg_tree_uncommon/max_right.hpp @@ -1,6 +1,7 @@ void max_right(int l, int r, auto f) { for (T x = unit; l < r;) { - int u = l + n, v = __lg(min(u & -u, r - l)), + int u = l + n, + v = bit_width(min(u & -u, r - l) + 0u) - 1, m = l + (1 << v); if (T y = op(x, s[u >> v]); f(m, y)) l = m, x = y; else r = m - 1; diff --git a/library/data_structures_[l,r)/seg_tree_uncommon/min_left.hpp b/library/data_structures_[l,r)/seg_tree_uncommon/min_left.hpp index 63672114..5d5e06c6 100644 --- a/library/data_structures_[l,r)/seg_tree_uncommon/min_left.hpp +++ b/library/data_structures_[l,r)/seg_tree_uncommon/min_left.hpp @@ -1,6 +1,7 @@ void min_left(int l, int r, auto f) { for (T x = unit; l < r;) { - int u = r + n, v = __lg(min(u & -u, r - l)), + int u = r + n, + v = bit_width(min(u & -u, r - l) + 0u) - 1, m = r - (1 << v); if (T y = op(s[(u - 1) >> v], x); f(m, y)) r = m, x = y; diff --git a/library/data_structures_[l,r)/uncommon/deque_op.hpp b/library/data_structures_[l,r)/uncommon/deque_op.hpp index de2975cc..e6a950cb 100644 --- a/library/data_structures_[l,r)/uncommon/deque_op.hpp +++ b/library/data_structures_[l,r)/uncommon/deque_op.hpp @@ -58,9 +58,10 @@ template struct deq { partial_sum(sz_le + all(a), begin(presum) + sz_le, op); l.resize(sz_le); r.resize(sz(a) - sz_le); - transform(begin(a), begin(a) + sz_le, begin(presum), + ranges::transform(a | views::take(sz_le), presum, rbegin(l), [](T x, T y) { return dt{x, y}; }); - transform(sz_le + all(a), begin(presum) + sz_le, - begin(r), [](T x, T y) { return dt{x, y}; }); + ranges::transform(a | views::drop(sz_le), + presum | views::drop(sz_le), begin(r), + [](T x, T y) { return dt{x, y}; }); } }; diff --git a/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp b/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp index 2c312d94..9dfad1eb 100644 --- a/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp +++ b/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp @@ -38,9 +38,10 @@ template struct pq_updates { extra.push_back(upd_st[idx_sk]); idx = min(idx, idx_sk), lowest_pri = pri; } - auto it = remove_if(idx + all(upd_st), [&](auto& cur) { - return cur.second->first >= lowest_pri; - }); + auto it = begin(ranges::remove_if( + upd_st | views::drop(idx), [&](auto& cur) { + return cur.second->first >= lowest_pri; + })); ranges::reverse_copy(extra, it); rep(i, idx, sz(upd_st)) ds.undo(); upd_st.pop_back(); diff --git a/library/data_structures_[l,r]/disjoint_rmq.hpp b/library/data_structures_[l,r]/disjoint_rmq.hpp index 5df9ac63..fc105e79 100644 --- a/library/data_structures_[l,r]/disjoint_rmq.hpp +++ b/library/data_structures_[l,r]/disjoint_rmq.hpp @@ -27,7 +27,7 @@ template struct disjoint_rmq { } T query(int l, int r) { if (l == r) return dp[0][l]; - int lg = __lg(l ^ r); + int lg = bit_width((l ^ r) + 0u) - 1; return op(dp[lg][l], dp[lg][r]); } }; diff --git a/library/data_structures_[l,r]/rmq.hpp b/library/data_structures_[l,r]/rmq.hpp index b7d58b9f..d6014fce 100644 --- a/library/data_structures_[l,r]/rmq.hpp +++ b/library/data_structures_[l,r]/rmq.hpp @@ -23,7 +23,7 @@ template struct RMQ { } T query(int l, int r) { assert(l <= r); - int lg = __lg(r - l + 1); + int lg = bit_width(r - l + 1u) - 1; return op(dp[lg][l], dp[lg][r - (1 << lg) + 1]); } }; diff --git a/library/data_structures_[l,r]/seg_tree.hpp b/library/data_structures_[l,r]/seg_tree.hpp index e2a0a362..0b1661e5 100644 --- a/library/data_structures_[l,r]/seg_tree.hpp +++ b/library/data_structures_[l,r]/seg_tree.hpp @@ -17,7 +17,8 @@ //! @time O(n + q log n) //! @space O(n) int nxt(int& l, int r) { - int u = l, v = __lg(min(l & -l, r - l + 1)); + int u = l, + v = bit_width(min(l & -l, r - l + 1) + 0u) - 1; return l += 1 << v, u >> v; } template struct tree { diff --git a/library/data_structures_[l,r]/seg_tree_uncommon/max_right.hpp b/library/data_structures_[l,r]/seg_tree_uncommon/max_right.hpp index 286c19d4..a1eb7bff 100644 --- a/library/data_structures_[l,r]/seg_tree_uncommon/max_right.hpp +++ b/library/data_structures_[l,r]/seg_tree_uncommon/max_right.hpp @@ -1,7 +1,8 @@ void max_right(int l, int r, auto f) { if (T x = s[l + n]; f(l, x)) for (l++; l <= r;) { - int u = l + n, v = __lg(min(u & -u, r - l + 1)), + int u = l + n, + v = bit_width(min(u & -u, r - l + 1) + 0u) - 1, m = l + (1 << v) - 1; if (T y = op(x, s[u >> v]); f(m, y)) l = m + 1, x = y; diff --git a/library/data_structures_[l,r]/seg_tree_uncommon/min_left.hpp b/library/data_structures_[l,r]/seg_tree_uncommon/min_left.hpp index d52d401d..7be67857 100644 --- a/library/data_structures_[l,r]/seg_tree_uncommon/min_left.hpp +++ b/library/data_structures_[l,r]/seg_tree_uncommon/min_left.hpp @@ -1,7 +1,8 @@ int min_left(int l, int r, auto f) { if (T x = s[r + n]; f(r, x)) for (r--; l <= r;) { - int u = r + 1 + n, v = __lg(min(u & -u, r - l + 1)), + int u = r + 1 + n, + v = bit_width(min(u & -u, r - l + 1) + 0u) - 1, m = r - (1 << v) + 1; if (T y = op(s[(u - 1) >> v], x); f(m, y)) r = m - 1, x = y; diff --git a/library/dsu/range_parallel_dsu.hpp b/library/dsu/range_parallel_dsu.hpp index d18b4e91..2114eb3c 100644 --- a/library/dsu/range_parallel_dsu.hpp +++ b/library/dsu/range_parallel_dsu.hpp @@ -9,7 +9,7 @@ struct rp_dsu { vector dsus; rp_dsu(int n): dsus(bit_width(n + 0u), DSU(n)) {} void join(int u, int v, int len, auto f) { - int i = __lg(len); + int i = bit_width(len + 0u) - 1; join(u, v, f, i); join(u + len - (1 << i), v + len - (1 << i), f, i); } diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index ae03effe..fd86a137 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -33,9 +33,10 @@ vi offline_incremental_scc(vector> eds, } rep(i, 0, sz(g)) ids[vs[i]] = -1; scc_id = scc(g).second; - auto split = partition(el, er, [&](int i) { - return scc_id[eds[i][0]] == scc_id[eds[i][1]]; - }); + auto split = begin(ranges::partition( + ranges::subrange(el, er), [&](int i) { + return scc_id[eds[i][0]] == scc_id[eds[i][1]]; + })); for (auto it = el; it != split; it++) joins[*it] = mid; if (tr - tl == 1) return; for (auto it = split; it != er; it++) { diff --git a/library/strings/suffix_array/find/find_string_bs_fast.hpp b/library/strings/suffix_array/find/find_string_bs_fast.hpp index f6d09d33..a543c21a 100644 --- a/library/strings/suffix_array/find/find_string_bs_fast.hpp +++ b/library/strings/suffix_array/find/find_string_bs_fast.hpp @@ -10,8 +10,8 @@ match find_str_fast(const T& t) { if (int lcp_len = s_l == n ? 0 : len_lcp(s_l, i); lcp_len != s_len) return (lcp_len < s_len) ^ (cmp_sufs(s_l, i) < 0); - auto [it_s, it_t] = - mismatch(i + s_len + all(s), s_len + all(t)); + auto [it_s, it_t] = ranges::mismatch( + s | views::drop(i + s_len), t | views::drop(s_len)); s_l = i, s_len = it_t - begin(t); return lexicographical_compare(it_s, end(s), it_t, end(t)); @@ -19,7 +19,7 @@ match find_str_fast(const T& t) { int sa_le = ranges::lower_bound(sa, 0, cmp) - begin(sa), sa_ri = sa_le; if (s_len == sz(t)) - sa_ri = lower_bound(sa_le + all(sa), 0, + sa_ri = ranges::lower_bound(sa | views::drop(sa_le), 0, [&](int i, int) -> bool { return len_lcp(s_l, i) >= sz(t); }) - diff --git a/library/strings/suffix_array/find/find_substring.hpp b/library/strings/suffix_array/find/find_substring.hpp index e882ac98..aff5b30a 100644 --- a/library/strings/suffix_array/find/find_substring.hpp +++ b/library/strings/suffix_array/find/find_substring.hpp @@ -16,10 +16,11 @@ pii find_substr(int s_l, int s_r) { auto cmp = [&](int i, bool flip) -> bool { return flip ^ (len_lcp(i, s_l) < s_r - s_l); }; - int l = lower_bound(begin(sa), begin(sa) + sa_inv[s_l], - 0, cmp) - + int l = ranges::lower_bound( + sa | views::take(sa_inv[s_l]), 0, cmp) - begin(sa); - int r = lower_bound(sa_inv[s_l] + 1 + all(sa), 1, cmp) - + int r = ranges::lower_bound( + sa | views::drop(sa_inv[s_l] + 1), 1, cmp) - begin(sa); return {l, r}; } diff --git a/library/trees/edge_cd.hpp b/library/trees/edge_cd.hpp index b7ed52c8..2d1de8fb 100644 --- a/library/trees/edge_cd.hpp +++ b/library/trees/edge_cd.hpp @@ -28,10 +28,10 @@ template void edge_cd(vector& g, auto f) { if (m < 2) return; u = ctd(ctd, u, u, m); int sum = 0; - auto it = partition(all(g[u]), [&](int v) { + auto it = begin(ranges::partition(g[u], [&](int v) { ll x = sum + s[v]; return x * x < m * (m - x) ? sum = x : 0; - }); + })); f(u, it - begin(g[u])); G oth(it, end(g[u])); g[u].erase(it, end(g[u])); diff --git a/library/trees/uncommon/ladder_decomposition.hpp b/library/trees/uncommon/ladder_decomposition.hpp index ae1435b4..bc9e31e5 100644 --- a/library/trees/uncommon/ladder_decomposition.hpp +++ b/library/trees/uncommon/ladder_decomposition.hpp @@ -44,7 +44,7 @@ struct ladder { int kth_par(int u, int k) { assert(0 <= k && k <= d[u]); if (k == 0) return u; - int bit = __lg(k); + int bit = bit_width(k + 0u) - 1; u = jmp[bit][u], k -= (1 << bit); int i = idx[u], j = i + d[lad[i]] - d[u]; assert(lad[j] == u); diff --git a/library/trees/uncommon/linear_kth_par.hpp b/library/trees/uncommon/linear_kth_par.hpp index 5ca8eaba..f5224ce8 100644 --- a/library/trees/uncommon/linear_kth_par.hpp +++ b/library/trees/uncommon/linear_kth_par.hpp @@ -50,7 +50,8 @@ struct linear_kth_par { if (k == 0) return u; int anc_d = d[u] - k, bc = bit_ceil(k + 0u); int t = (tin[u] + bc / 2) & -bc; - int i = idx[jmp[t].at(__lg(d_tour[t] - anc_d))]; + int i = idx[jmp[t].at( + bit_width(d_tour[t] - anc_d + 0u) - 1)]; return lad[i + d[lad[i]] - anc_d]; } }; From 952203032c0aae742e6bd3960cf1aafa1a859137 Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 12:36:02 -0700 Subject: [PATCH 11/12] suppress cppcheck mismatchingContainerExpression false positive on ranges::unique in virtual_tree --- tests/.config/.cppcheck_suppression_list | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/.config/.cppcheck_suppression_list b/tests/.config/.cppcheck_suppression_list index 8aef4c91..b6799b01 100644 --- a/tests/.config/.cppcheck_suppression_list +++ b/tests/.config/.cppcheck_suppression_list @@ -60,5 +60,6 @@ unusedFunction:../kactl/content/data-structures/UnionFind.h:14 unusedFunction:../kactl/content/number-theory/ModPow.h:13 unusedFunction:../kactl/stress-tests/utilities/genTree.h:49 containerOutOfBounds:../library/data_structures_[l,r)/uncommon/permutation_tree.hpp:85 +mismatchingContainerExpression:../library/trees/extra_members/virtual_tree.hpp:19 ctuOneDefinitionRuleViolation:../library/data_structures_[l,r)/bit.hpp:15 ctuOneDefinitionRuleViolation:../library/data_structures_[l,r)/lazy_seg_tree.hpp:4 From f6c6b6a35cdb17bc869f893c561d65b62ba0e537 Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Mon, 6 Jul 2026 12:53:51 -0700 Subject: [PATCH 12/12] revert subrange-returning ranges algos (unique/remove_if/partition) to iterator form; drop cppcheck suppression --- .../uncommon/priority_queue_of_updates.hpp | 7 +++---- .../offline_incremental_scc.hpp | 7 +++---- library/trees/edge_cd.hpp | 4 ++-- library/trees/extra_members/virtual_tree.hpp | 2 +- tests/.config/.cppcheck_suppression_list | 1 - 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp b/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp index 9dfad1eb..2c312d94 100644 --- a/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp +++ b/library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp @@ -38,10 +38,9 @@ template struct pq_updates { extra.push_back(upd_st[idx_sk]); idx = min(idx, idx_sk), lowest_pri = pri; } - auto it = begin(ranges::remove_if( - upd_st | views::drop(idx), [&](auto& cur) { - return cur.second->first >= lowest_pri; - })); + auto it = remove_if(idx + all(upd_st), [&](auto& cur) { + return cur.second->first >= lowest_pri; + }); ranges::reverse_copy(extra, it); rep(i, idx, sz(upd_st)) ds.undo(); upd_st.pop_back(); diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index fd86a137..ae03effe 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -33,10 +33,9 @@ vi offline_incremental_scc(vector> eds, } rep(i, 0, sz(g)) ids[vs[i]] = -1; scc_id = scc(g).second; - auto split = begin(ranges::partition( - ranges::subrange(el, er), [&](int i) { - return scc_id[eds[i][0]] == scc_id[eds[i][1]]; - })); + auto split = partition(el, er, [&](int i) { + return scc_id[eds[i][0]] == scc_id[eds[i][1]]; + }); for (auto it = el; it != split; it++) joins[*it] = mid; if (tr - tl == 1) return; for (auto it = split; it != er; it++) { diff --git a/library/trees/edge_cd.hpp b/library/trees/edge_cd.hpp index 2d1de8fb..b7ed52c8 100644 --- a/library/trees/edge_cd.hpp +++ b/library/trees/edge_cd.hpp @@ -28,10 +28,10 @@ template void edge_cd(vector& g, auto f) { if (m < 2) return; u = ctd(ctd, u, u, m); int sum = 0; - auto it = begin(ranges::partition(g[u], [&](int v) { + auto it = partition(all(g[u]), [&](int v) { ll x = sum + s[v]; return x * x < m * (m - x) ? sum = x : 0; - })); + }); f(u, it - begin(g[u])); G oth(it, end(g[u])); g[u].erase(it, end(g[u])); diff --git a/library/trees/extra_members/virtual_tree.hpp b/library/trees/extra_members/virtual_tree.hpp index 674cd432..2526dc0e 100644 --- a/library/trees/extra_members/virtual_tree.hpp +++ b/library/trees/extra_members/virtual_tree.hpp @@ -16,7 +16,7 @@ array compress_tree(vi subset) { rep(i, 1, len) subset.push_back(lca(subset[i - 1], subset[i])); ranges::sort(subset, {}, proj); - subset.erase(begin(ranges::unique(subset)), end(subset)); + subset.erase(unique(all(subset)), end(subset)); return { mono_st(subset, [&](int u, int v) { return in_subtree(u, v); }), diff --git a/tests/.config/.cppcheck_suppression_list b/tests/.config/.cppcheck_suppression_list index b6799b01..8aef4c91 100644 --- a/tests/.config/.cppcheck_suppression_list +++ b/tests/.config/.cppcheck_suppression_list @@ -60,6 +60,5 @@ unusedFunction:../kactl/content/data-structures/UnionFind.h:14 unusedFunction:../kactl/content/number-theory/ModPow.h:13 unusedFunction:../kactl/stress-tests/utilities/genTree.h:49 containerOutOfBounds:../library/data_structures_[l,r)/uncommon/permutation_tree.hpp:85 -mismatchingContainerExpression:../library/trees/extra_members/virtual_tree.hpp:19 ctuOneDefinitionRuleViolation:../library/data_structures_[l,r)/bit.hpp:15 ctuOneDefinitionRuleViolation:../library/data_structures_[l,r)/lazy_seg_tree.hpp:4