From b7918736207e55a55a53b2e57af7ffa401d27e62 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 18 Jan 2026 02:59:09 -0700 Subject: [PATCH 1/8] Refactor update and query methods in lazy_seg_tree --- .../data_structures_[l,r]/lazy_seg_tree.hpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/library/data_structures_[l,r]/lazy_seg_tree.hpp b/library/data_structures_[l,r]/lazy_seg_tree.hpp index 411e27b0..33377ce5 100644 --- a/library/data_structures_[l,r]/lazy_seg_tree.hpp +++ b/library/data_structures_[l,r]/lazy_seg_tree.hpp @@ -22,29 +22,29 @@ struct seg_tree { lazy[v] = 0; } } - void update(int l, int r, ll change) { // [l, r] - update_impl(l, r, change, 0, n - 1, 1); + void update(int l, int r, ll change) { + update(l, r, change, 0, n - 1, 1); } - void update_impl(int l, int r, ll change, int tl, int tr, + void update(int l, int r, ll change, int tl, int tr, int v) { if (r < tl || tr < l) return; if (l <= tl && tr <= r) return apply(change, tl, tr, v); int tm = split(tl, tr); push(tl, tm, tr, v); - update_impl(l, r, change, tl, tm, 2 * v); - update_impl(l, r, change, tm + 1, tr, 2 * v + 1); + update(l, r, change, tl, tm, 2 * v); + update(l, r, change, tm + 1, tr, 2 * v + 1); tree[v] = op(tree[2 * v], tree[2 * v + 1]); } - ll query(int l, int r) { // [l, r] - return query_impl(l, r, 0, n - 1, 1); + ll query(int l, int r) { + return query(l, r, 0, n - 1, 1); } - ll query_impl(int l, int r, int tl, int tr, int v) { + ll query(int l, int r, int tl, int tr, int v) { if (r < tl || tr < l) return 0; if (l <= tl && tr <= r) return tree[v]; int tm = split(tl, tr); push(tl, tm, tr, v); - return op(query_impl(l, r, tl, tm, 2 * v), - query_impl(l, r, tm + 1, tr, 2 * v + 1)); + return op(query(l, r, tl, tm, 2 * v), + query(l, r, tm + 1, tr, 2 * v + 1)); } }; From 9db9cd73838d75344dfa9c6770675d50a7e1eeb1 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 18 Jan 2026 10:01:52 +0000 Subject: [PATCH 2/8] [auto-verifier] verify commit b7918736207e55a55a53b2e57af7ffa401d27e62 --- .verify-helper/timestamps.remote.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 5b8c8d44..aaf3ff5f 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -28,8 +28,8 @@ "tests/library_checker_aizu_tests/data_structures/kth_smallest_wavelet_matrix.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/lazy_segment_tree.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_constructor.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc_constructor.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc.test.cpp": "2026-01-18 02:59:09 -0700", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc_constructor.test.cpp": "2026-01-18 02:59:09 -0700", "tests/library_checker_aizu_tests/data_structures/line_tree_aizu.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2026-01-18 02:20:40 +0000", From 40743836797e5ee0c5de25ddfa13a755298bfd8c Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 18 Jan 2026 03:03:57 -0700 Subject: [PATCH 3/8] Refactor lazy segment tree methods for clarity --- library/data_structures_[l,r)/lazy_seg_tree.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/data_structures_[l,r)/lazy_seg_tree.hpp b/library/data_structures_[l,r)/lazy_seg_tree.hpp index 383a8d08..619cff0c 100644 --- a/library/data_structures_[l,r)/lazy_seg_tree.hpp +++ b/library/data_structures_[l,r)/lazy_seg_tree.hpp @@ -23,29 +23,29 @@ struct seg_tree { } } void update(int l, int r, ll change) { // [l, r) - update_impl(l, r, change, 0, n, 1); + update(l, r, change, 0, n, 1); } - void update_impl(int l, int r, ll change, int tl, int tr, + void update(int l, int r, ll change, int tl, int tr, int v) { if (r <= tl || tr <= l) return; if (l <= tl && tr <= r) return apply(change, tl, tr, v); int tm = split(tl, tr); push(tl, tm, tr, v); - update_impl(l, r, change, tl, tm, 2 * v); - update_impl(l, r, change, tm, tr, 2 * v + 1); + update(l, r, change, tl, tm, 2 * v); + update(l, r, change, tm, tr, 2 * v + 1); tree[v] = op(tree[2 * v], tree[2 * v + 1]); } ll query(int l, int r) { // [l, r) - return query_impl(l, r, 0, n, 1); + return query(l, r, 0, n, 1); } - ll query_impl(int l, int r, int tl, int tr, int v) { + ll query(int l, int r, int tl, int tr, int v) { if (r <= tl || tr <= l) return 0; if (l <= tl && tr <= r) return tree[v]; int tm = split(tl, tr); push(tl, tm, tr, v); - return op(query_impl(l, r, tl, tm, 2 * v), - query_impl(l, r, tm, tr, 2 * v + 1)); + return op(query(l, r, tl, tm, 2 * v), + query(l, r, tm, tr, 2 * v + 1)); } #include "seg_tree_uncommon/find_first.hpp" #include "seg_tree_uncommon/find_last.hpp" From 85e20f4db8b788a9124f328de2e191937004c001 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 18 Jan 2026 03:05:20 -0700 Subject: [PATCH 4/8] Update persistent.hpp --- .../seg_tree_uncommon/persistent.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/data_structures_[l,r)/seg_tree_uncommon/persistent.hpp b/library/data_structures_[l,r)/seg_tree_uncommon/persistent.hpp index 722aa780..25139474 100644 --- a/library/data_structures_[l,r)/seg_tree_uncommon/persistent.hpp +++ b/library/data_structures_[l,r)/seg_tree_uncommon/persistent.hpp @@ -22,10 +22,10 @@ struct PST { root_l(root_l), root_r(root_r), roots(1), tree(1, {0LL, 0, 0}) {} void update(int idx, ll change, int version) { - roots.push_back(update_impl(idx, change, root_l, + roots.push_back(update(idx, change, root_l, root_r, roots[version])); } - int update_impl(int idx, ll change, int tl, int tr, + int update(int idx, ll change, int tl, int tr, int v) { if (tr - tl == 1) { tree.emplace_back(tree[v].sum + change, 0, 0); @@ -35,21 +35,21 @@ struct PST { int lch = tree[v].lch; int rch = tree[v].rch; if (idx < tm) - lch = update_impl(idx, change, tl, tm, lch); - else rch = update_impl(idx, change, tm, tr, rch); + lch = update(idx, change, tl, tm, lch); + else rch = update(idx, change, tm, tr, rch); tree.emplace_back(tree[lch].sum + tree[rch].sum, lch, rch); return sz(tree) - 1; } ll query(int l, int r, int version) { // [l, r) - return query_impl(l, r, root_l, root_r, + return query(l, r, root_l, root_r, roots[version]); } - ll query_impl(int l, int r, int tl, int tr, int v) { + ll query(int l, int r, int tl, int tr, int v) { if (v == 0 || r <= tl || tr <= l) return 0; if (l <= tl && tr <= r) return tree[v].sum; int tm = tl + (tr - tl) / 2; - return query_impl(l, r, tl, tm, tree[v].lch) + - query_impl(l, r, tm, tr, tree[v].rch); + return query(l, r, tl, tm, tree[v].lch) + + query(l, r, tm, tr, tree[v].rch); } }; From cae666b10f81c8ecdf15db8b7db75d2a7a547514 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 18 Jan 2026 03:06:14 -0700 Subject: [PATCH 5/8] Rename query_impl to query for clarity --- .../seg_tree_uncommon/kth_smallest_query.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp b/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp index 51d9a9b4..3a72b8f5 100644 --- a/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp +++ b/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp @@ -20,18 +20,18 @@ struct kth_smallest { //! @space O(log(maxv - minv)) for recursion stack; no //! new nodes are allocated int query(int l, int r, int k) { - return query_impl(k, pst.root_l, pst.root_r, + return query(k, pst.root_l, pst.root_r, pst.roots[l], pst.roots[r]); } - int query_impl(int k, int tl, int tr, int vl, int vr) { + int query(int k, int tl, int tr, int vl, int vr) { if (tr - tl == 1) return tl; int tm = tl + (tr - tl) / 2; int left_count = pst.tree[pst.tree[vr].lch].sum - pst.tree[pst.tree[vl].lch].sum; if (left_count >= k) - return query_impl(k, tl, tm, pst.tree[vl].lch, + return query(k, tl, tm, pst.tree[vl].lch, pst.tree[vr].lch); - return query_impl(k - left_count, tm, tr, + return query(k - left_count, tm, tr, pst.tree[vl].rch, pst.tree[vr].rch); } }; From b919a22ba876946490cfda0117267a0b0419a858 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 18 Jan 2026 03:06:56 -0700 Subject: [PATCH 6/8] Rename query_impl to query for clarity --- .../seg_tree_uncommon/merge_sort_tree.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/data_structures_[l,r)/seg_tree_uncommon/merge_sort_tree.hpp b/library/data_structures_[l,r)/seg_tree_uncommon/merge_sort_tree.hpp index 54a44dd9..ecdcf7b3 100644 --- a/library/data_structures_[l,r)/seg_tree_uncommon/merge_sort_tree.hpp +++ b/library/data_structures_[l,r)/seg_tree_uncommon/merge_sort_tree.hpp @@ -14,16 +14,16 @@ struct merge_sort_tree { //! @time O(log(n)^2) //! @space O(1) int query(int l, int r, int vl, int vr) { - return query_impl(l, r, vl, vr, 0, n, 1); + return query(l, r, vl, vr, 0, n, 1); } - int query_impl(int l, int r, int vl, int vr, int tl, + int query(int l, int r, int vl, int vr, int tl, int tr, int v) { if (r <= tl || tr <= l) return 0; if (l <= tl && tr <= r) return ranges::lower_bound(tree[v], vr) - ranges::lower_bound(tree[v], vl); int tm = split(tl, tr); - return query_impl(l, r, vl, vr, tl, tm, 2 * v) + - query_impl(l, r, vl, vr, tm, tr, 2 * v + 1); + return query(l, r, vl, vr, tl, tm, 2 * v) + + query(l, r, vl, vr, tm, tr, 2 * v + 1); } }; From f4afe7c64df1a599550d2b933ebb29309f7cc922 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 18 Jan 2026 10:18:25 +0000 Subject: [PATCH 7/8] [auto-verifier] verify commit b919a22ba876946490cfda0117267a0b0419a858 --- .verify-helper/timestamps.remote.json | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index aaf3ff5f..d7a9e85e 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -4,12 +4,12 @@ "tests/library_checker_aizu_tests/convolution/min_plus_convolution.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/data_structures/binary_search_example.test.cpp": "2024-11-18 10:51:39 -0600", "tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/bit.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/bit.test.cpp": "2026-01-18 03:03:57 -0700", "tests/library_checker_aizu_tests/data_structures/bit_inc.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/bit_rupq.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/bit_rurq.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/bit_walk.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/bit_walk.test.cpp": "2026-01-18 03:03:57 -0700", "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", @@ -17,26 +17,26 @@ "tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc_lines.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc_sum.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/distinct_query.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/distinct_query.test.cpp": "2026-01-18 03:05:20 -0700", "tests/library_checker_aizu_tests/data_structures/dsu.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/dsu_bipartite.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/dsu_restorable.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/dsu_segtree_undo_trick.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/dsu_segtree_undo_trick.test.cpp": "2026-01-18 03:03:57 -0700", "tests/library_checker_aizu_tests/data_structures/implicit_seg_tree.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/kruskal_tree_aizu.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp": "2026-01-18 03:06:14 -0700", "tests/library_checker_aizu_tests/data_structures/kth_smallest_wavelet_matrix.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_constructor.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree.test.cpp": "2026-01-18 03:03:57 -0700", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_constructor.test.cpp": "2026-01-18 03:03:57 -0700", "tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc.test.cpp": "2026-01-18 02:59:09 -0700", "tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc_constructor.test.cpp": "2026-01-18 02:59:09 -0700", "tests/library_checker_aizu_tests/data_structures/line_tree_aizu.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2026-01-18 03:06:56 -0700", "tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2026-01-18 03:05:20 -0700", +"tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2026-01-18 03:05:20 -0700", "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_with_dsu.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2026-01-18 02:20:40 +0000", @@ -75,15 +75,15 @@ "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/hilbert_mos.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2026-01-18 03:06:56 -0700", "tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/handmade_tests/mod_division.test.cpp": "2025-09-07 16:12:35 -0600", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2025-08-28 13:19:16 -0600", "tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2026-01-18 03:03:57 -0700", +"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2026-01-18 03:03:57 -0700", "tests/library_checker_aizu_tests/loops/chooses.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/loops/quotients.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/loops/submasks.test.cpp": "2025-02-10 14:50:36 -0700", @@ -112,7 +112,7 @@ "tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2026-01-18 02:20:40 +0000", "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-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2026-01-18 03:06:56 -0700", "tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2025-08-05 19:19:23 -0600", "tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2025-08-05 19:19:23 -0600", @@ -129,7 +129,7 @@ "tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2025-12-11 21:47:53 +0000", "tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2025-09-07 15:50:55 -0600", "tests/library_checker_aizu_tests/trees/hld_aizu1.test.cpp": "2026-01-18 02:20:40 +0000", -"tests/library_checker_aizu_tests/trees/hld_aizu2.test.cpp": "2026-01-18 02:20:40 +0000", +"tests/library_checker_aizu_tests/trees/hld_aizu2.test.cpp": "2026-01-18 03:03:57 -0700", "tests/library_checker_aizu_tests/trees/hld_lib_checker_path.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/trees/hld_lib_checker_subtree_edges.test.cpp": "2026-01-18 02:20:40 +0000", "tests/library_checker_aizu_tests/trees/hld_lib_checker_subtree_nodes.test.cpp": "2026-01-18 02:20:40 +0000", From 3c5263c959d424b60a23c8f5726014c1be0ee84f Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 18 Jan 2026 03:30:52 -0700 Subject: [PATCH 8/8] format --- .../seg_tree_uncommon/kth_smallest_query.hpp | 8 ++++---- .../seg_tree_uncommon/merge_sort_tree.hpp | 4 ++-- .../seg_tree_uncommon/persistent.hpp | 13 +++++-------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp b/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp index 3a72b8f5..9da3ba8c 100644 --- a/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp +++ b/library/data_structures_[l,r)/seg_tree_uncommon/kth_smallest_query.hpp @@ -20,8 +20,8 @@ struct kth_smallest { //! @space O(log(maxv - minv)) for recursion stack; no //! new nodes are allocated int query(int l, int r, int k) { - return query(k, pst.root_l, pst.root_r, - pst.roots[l], pst.roots[r]); + return query(k, pst.root_l, pst.root_r, pst.roots[l], + pst.roots[r]); } int query(int k, int tl, int tr, int vl, int vr) { if (tr - tl == 1) return tl; @@ -31,7 +31,7 @@ struct kth_smallest { if (left_count >= k) return query(k, tl, tm, pst.tree[vl].lch, pst.tree[vr].lch); - return query(k - left_count, tm, tr, - pst.tree[vl].rch, pst.tree[vr].rch); + return query(k - left_count, tm, tr, pst.tree[vl].rch, + pst.tree[vr].rch); } }; diff --git a/library/data_structures_[l,r)/seg_tree_uncommon/merge_sort_tree.hpp b/library/data_structures_[l,r)/seg_tree_uncommon/merge_sort_tree.hpp index ecdcf7b3..71fd0172 100644 --- a/library/data_structures_[l,r)/seg_tree_uncommon/merge_sort_tree.hpp +++ b/library/data_structures_[l,r)/seg_tree_uncommon/merge_sort_tree.hpp @@ -16,8 +16,8 @@ struct merge_sort_tree { int query(int l, int r, int vl, int vr) { return query(l, r, vl, vr, 0, n, 1); } - int query(int l, int r, int vl, int vr, int tl, - int tr, int v) { + int query(int l, int r, int vl, int vr, int tl, int tr, + int v) { if (r <= tl || tr <= l) return 0; if (l <= tl && tr <= r) return ranges::lower_bound(tree[v], vr) - diff --git a/library/data_structures_[l,r)/seg_tree_uncommon/persistent.hpp b/library/data_structures_[l,r)/seg_tree_uncommon/persistent.hpp index 25139474..e883281b 100644 --- a/library/data_structures_[l,r)/seg_tree_uncommon/persistent.hpp +++ b/library/data_structures_[l,r)/seg_tree_uncommon/persistent.hpp @@ -22,11 +22,10 @@ struct PST { root_l(root_l), root_r(root_r), roots(1), tree(1, {0LL, 0, 0}) {} void update(int idx, ll change, int version) { - roots.push_back(update(idx, change, root_l, - root_r, roots[version])); + roots.push_back( + update(idx, change, root_l, root_r, roots[version])); } - int update(int idx, ll change, int tl, int tr, - int v) { + int update(int idx, ll change, int tl, int tr, int v) { if (tr - tl == 1) { tree.emplace_back(tree[v].sum + change, 0, 0); return sz(tree) - 1; @@ -34,16 +33,14 @@ struct PST { int tm = tl + (tr - tl) / 2; int lch = tree[v].lch; int rch = tree[v].rch; - if (idx < tm) - lch = update(idx, change, tl, tm, lch); + if (idx < tm) lch = update(idx, change, tl, tm, lch); else rch = update(idx, change, tm, tr, rch); tree.emplace_back(tree[lch].sum + tree[rch].sum, lch, rch); return sz(tree) - 1; } ll query(int l, int r, int version) { // [l, r) - return query(l, r, root_l, root_r, - roots[version]); + return query(l, r, root_l, root_r, roots[version]); } ll query(int l, int r, int tl, int tr, int v) { if (v == 0 || r <= tl || tr <= l) return 0;