From 1f5281b19d7f3ad29db9d9cfbb3979fc72691b5e Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 15:23:53 -0600 Subject: [PATCH 01/21] different style + nits --- .../data_structures/uncommon/linear_rmq.hpp | 44 +++++++++---------- .../data_structures/rmq_linear.test.cpp | 8 ++-- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index 503308a8..cb1ada24 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -1,10 +1,10 @@ #pragma once //! https://codeforces.com/blog/entry/125371?#comment-1173604 //! @code -//! linear_rmq rmq1(a, less());//right-most min -//! linear_rmq rmq2(a, less_equal());//left-most min -//! linear_rmq rmq3(a, greater());//right-most max -//! linear_rmq rmq4(a, greater_equal());//left-most max +//! linear_rmq rmq1(a, less()); //right-most min +//! linear_rmq rmq2(a, less_equal()); //left-most min +//! linear_rmq rmq3(a, greater()); //right-most max +//! linear_rmq rmq4(a, greater_equal()); //left-most max //! linear_rmq rmq5(a, [&](auto& x, auto& y) { //! return x < y; //! }); @@ -12,38 +12,38 @@ //! @time O(n + q) //! @space O(n) template struct linear_rmq { + int n; vector a; F cmp; - vi head; - vector> t; + vi asc, in, head; linear_rmq(const vector& a, F cmp): - a(a), cmp(cmp), head(sz(a) + 1), t(sz(a)) { + n(sz(a)), a(a), cmp(cmp), asc(n), in(n), head(n + 1) { vi st{-1}; - for (int i = 0; i <= sz(a); i++) { + rep(i, 0, n + 1) { int prev = -1; while (st.back() != -1 && - (i == sz(a) || !cmp(a[st.back()], a[i]))) { + (i == n || !cmp(a[st.back()], a[i]))) { if (prev != -1) head[prev] = st.back(); - int pw2 = 1 << __lg((end(st)[-2] + 1) ^ i); - t[st.back()][0] = prev = i & -pw2; + int pw2 = bit_floor((end(st)[-2] + 1u) ^ i); + in[st.back()] = prev = i & -pw2; st.pop_back(); - t[st.back() + 1][1] |= pw2; + asc[st.back() + 1] |= pw2; } if (prev != -1) head[prev] = i; st.push_back(i); } - rep(i, 1, sz(a)) t[i][1] = - (t[i][1] | t[i - 1][1]) & -(t[i][0] & -t[i][0]); + rep(i, 1, n) asc[i] = + (asc[i] | asc[i - 1]) & -(in[i] & -in[i]); } - int query_idx(int l, int r) { // [l, r] - if (unsigned j = t[l][0] ^ t[r][0]; j) { - j = t[l][1] & t[r][1] & -bit_floor(j); - if (unsigned k = t[l][1] ^ j; k) - k = bit_floor(k), l = head[(t[l][0] & -k) | k]; - if (unsigned k = t[r][1] ^ j; k) - k = bit_floor(k), r = head[(t[r][0] & -k) | k]; + int idx(int l, int r) { // [l, r] + if (unsigned j = in[l] ^ in[r]; j) { + j = asc[l] & asc[r] & -bit_floor(j); + if (unsigned k = asc[l] ^ j; k) + k = bit_floor(k), l = head[(in[l] & -k) | k]; + if (unsigned k = asc[r] ^ j; k) + k = bit_floor(k), r = head[(in[r] & -k) | k]; } return cmp(a[l], a[r]) ? l : r; } - T query(int l, int r) { return a[query_idx(l, r)]; } + T query(int l, int r) { return a[idx(l, r)]; } }; diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp index 90a06dcf..87354eca 100644 --- a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp @@ -16,21 +16,21 @@ int main() { while (q--) { int l, r; cin >> l >> r; - int idx_right_min = rmq_less.query_idx(l, r - 1); + int idx_right_min = rmq_less.idx(l, r - 1); assert(idx_right_min + 1 == r || rmq_less.query(idx_right_min + 1, r - 1) > a[idx_right_min]); assert(l <= idx_right_min && idx_right_min < r); assert(rmq_less.query(l, r - 1) == a[idx_right_min]); assert( - idx_right_min == rmq_greater.query_idx(l, r - 1)); - int idx_left_min = rmq_less_equal.query_idx(l, r - 1); + idx_right_min == rmq_greater.idx(l, r - 1)); + int idx_left_min = rmq_less_equal.idx(l, r - 1); assert(l == idx_left_min || rmq_less_equal.query(l, idx_left_min - 1) > a[idx_left_min]); assert(l <= idx_left_min && idx_left_min < r); assert(idx_left_min == - rmq_greater_equal.query_idx(l, r - 1)); + rmq_greater_equal.idx(l, r - 1)); assert(a[idx_right_min] == a[idx_left_min]); assert(idx_left_min <= idx_right_min); cout << a[idx_right_min] << '\n'; From 9e9d53915ae0f7e2cc72dc7eb536cb40748dcd77 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 3 Aug 2025 21:35:53 +0000 Subject: [PATCH 02/21] [auto-verifier] verify commit 1f5281b19d7f3ad29db9d9cfbb3979fc72691b5e --- .verify-helper/timestamps.remote.json | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 904dc3cf..97c8b734 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -33,15 +33,14 @@ "tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2025-02-11 13:53:30 -0700", "tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2025-02-10 23:30:47 -0700", -"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-06-03 13:37:20 -0600", "tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-06-03 13:37:20 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-06-03 13:37:20 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 15:23:53 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 15:23:53 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-21 00:23:10 -0500", @@ -78,8 +77,6 @@ "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_int.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700", -"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-06-03 13:37:20 -0600", -"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-06-03 13:37:20 -0600", "tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 19:50:29 -0600", @@ -107,9 +104,9 @@ "tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2025-04-22 21:37:22 -0500", "tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-06-03 13:37:20 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-06-03 13:37:20 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-06-03 13:37:20 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 15:23:53 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 15:23:53 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 15:23:53 -0600", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2025-02-10 14:50:36 -0700", @@ -123,7 +120,7 @@ "tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-06-03 13:37:20 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 15:23:53 -0600", "tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600", From 278d08561eae60094da18ea3592ef093bd705d3e Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 15:40:30 -0600 Subject: [PATCH 03/21] fixes --- library/data_structures/uncommon/linear_rmq.hpp | 10 +++++----- library/data_structures/uncommon/permutation_tree.hpp | 4 ++-- .../handmade_tests/rmq_small_n.test.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index cb1ada24..629aa40c 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -24,16 +24,16 @@ template struct linear_rmq { while (st.back() != -1 && (i == n || !cmp(a[st.back()], a[i]))) { if (prev != -1) head[prev] = st.back(); - int pw2 = bit_floor((end(st)[-2] + 1u) ^ i); - in[st.back()] = prev = i & -pw2; + int b = bit_floor((end(st)[-2] + 1u) ^ i); + in[st.back()] = prev = i & -b; st.pop_back(); - asc[st.back() + 1] |= pw2; + asc[st.back() + 1] |= b; } if (prev != -1) head[prev] = i; st.push_back(i); } - rep(i, 1, n) asc[i] = - (asc[i] | asc[i - 1]) & -(in[i] & -in[i]); + rep(i, 1, n)(asc[i] |= asc[i - 1]) &= + -(in[i] & -in[i]); } int idx(int l, int r) { // [l, r] if (unsigned j = in[l] ^ in[r]; j) { diff --git a/library/data_structures/uncommon/permutation_tree.hpp b/library/data_structures/uncommon/permutation_tree.hpp index fbd98057..e5553677 100644 --- a/library/data_structures/uncommon/permutation_tree.hpp +++ b/library/data_structures/uncommon/permutation_tree.hpp @@ -37,8 +37,8 @@ struct perm_tree { linear_rmq rmq_min(a_inv, less()); linear_rmq rmq_max(a_inv, greater()); rep(i, 1, n) { - mn_i[i] = a_inv[rmq_min.query_idx(a[i - 1], a[i])]; - mx_i[i] = a_inv[rmq_max.query_idx(a[i - 1], a[i])]; + mn_i[i] = a_inv[rmq_min.idx(a[i - 1], a[i])]; + mx_i[i] = a_inv[rmq_max.idx(a[i - 1], a[i])]; } } rep(i, 0, n) allocate(i, a[i], 1, 0, {}); diff --git a/tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp index 8b97202f..2dbec0e4 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp @@ -13,7 +13,7 @@ void test_all_subarrays(const vector& a) { linear_rmq lin_rmq(a, less()); for (int l = 0; l < n; l++) { for (int r = l + 1; r <= n; r++) { - int idx_min = lin_rmq.query_idx(l, r - 1); + int idx_min = lin_rmq.idx(l, r - 1); assert(l <= idx_min && idx_min < r); assert(a[idx_min] == rmq.query(l, r)); assert(a[idx_min] == dis_rmq.query(l, r)); From d32ef9bb956a9f8bde70833e25aaee035f8c1e82 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 3 Aug 2025 21:54:33 +0000 Subject: [PATCH 04/21] [auto-verifier] verify commit 278d08561eae60094da18ea3592ef093bd705d3e --- .verify-helper/timestamps.remote.json | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 97c8b734..38de785e 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -33,14 +33,15 @@ "tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2025-02-11 13:53:30 -0700", "tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2025-02-10 23:30:47 -0700", +"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-08-03 15:40:30 -0600", "tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 15:23:53 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 15:23:53 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 15:40:30 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-21 00:23:10 -0500", @@ -77,6 +78,8 @@ "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_int.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700", +"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-08-03 15:40:30 -0600", "tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 19:50:29 -0600", @@ -104,9 +107,9 @@ "tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2025-04-22 21:37:22 -0500", "tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 15:23:53 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 15:23:53 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 15:23:53 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 15:40:30 -0600", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2025-02-10 14:50:36 -0700", @@ -120,7 +123,7 @@ "tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 15:23:53 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 15:40:30 -0600", "tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600", From 03e2059c08f363df1b18692ac7b3afe8aec4b27d Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 17:11:36 -0600 Subject: [PATCH 05/21] format --- .../data_structures/rmq_linear.test.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp index 87354eca..fb3de419 100644 --- a/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp @@ -22,15 +22,14 @@ int main() { a[idx_right_min]); assert(l <= idx_right_min && idx_right_min < r); assert(rmq_less.query(l, r - 1) == a[idx_right_min]); - assert( - idx_right_min == rmq_greater.idx(l, r - 1)); + assert(idx_right_min == rmq_greater.idx(l, r - 1)); int idx_left_min = rmq_less_equal.idx(l, r - 1); assert(l == idx_left_min || rmq_less_equal.query(l, idx_left_min - 1) > a[idx_left_min]); assert(l <= idx_left_min && idx_left_min < r); - assert(idx_left_min == - rmq_greater_equal.idx(l, r - 1)); + assert( + idx_left_min == rmq_greater_equal.idx(l, r - 1)); assert(a[idx_right_min] == a[idx_left_min]); assert(idx_left_min <= idx_right_min); cout << a[idx_right_min] << '\n'; From 93d2c19a1db18c29b7e49f21de8bcbfb19d36ce8 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 3 Aug 2025 23:13:37 +0000 Subject: [PATCH 06/21] [auto-verifier] verify commit 03e2059c08f363df1b18692ac7b3afe8aec4b27d --- .verify-helper/timestamps.remote.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 38de785e..dccde6a1 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -40,7 +40,7 @@ "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 17:11:36 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 15:40:30 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-14 15:47:13 -0600", From 78b05a3be2b222872d0a9f642b4bbe7e21697469 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 17:18:38 -0600 Subject: [PATCH 07/21] suppress --- 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 b49f37a0..a5be8a60 100644 --- a/tests/.config/.cppcheck_suppression_list +++ b/tests/.config/.cppcheck_suppression_list @@ -62,3 +62,4 @@ unusedFunction:../kactl/content/number-theory/ModPow.h:13 unusedFunction:../kactl/stress-tests/utilities/genTree.h:49 assertWithSideEffect:library_checker_aizu_tests/math/xor_basis_intersection.test.cpp:27 assertWithSideEffect:library_checker_aizu_tests/math/xor_basis_intersection.test.cpp:36 +containerOutOfBounds:../library/data_structures/uncommon/permutation_tree.hpp:85 From 60546c3fcb51a77ee74daaf1c3258f7b820e0cd4 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 17:30:02 -0600 Subject: [PATCH 08/21] another golf --- library/data_structures/uncommon/linear_rmq.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index 629aa40c..884bd532 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -21,7 +21,7 @@ template struct linear_rmq { vi st{-1}; rep(i, 0, n + 1) { int prev = -1; - while (st.back() != -1 && + while (sz(st) > 1 && (i == n || !cmp(a[st.back()], a[i]))) { if (prev != -1) head[prev] = st.back(); int b = bit_floor((end(st)[-2] + 1u) ^ i); From a2e47016dcd772c894b7fafef36b02ccb0473042 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 3 Aug 2025 23:44:05 +0000 Subject: [PATCH 09/21] [auto-verifier] verify commit 60546c3fcb51a77ee74daaf1c3258f7b820e0cd4 --- .verify-helper/timestamps.remote.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index dccde6a1..b63e01f6 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -33,15 +33,15 @@ "tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2025-02-11 13:53:30 -0700", "tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2025-02-10 23:30:47 -0700", -"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-08-03 17:30:02 -0600", "tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 17:11:36 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 17:30:02 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 17:30:02 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-21 00:23:10 -0500", @@ -78,8 +78,8 @@ "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_int.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700", -"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-08-03 15:40:30 -0600", -"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-08-03 17:30:02 -0600", +"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-08-03 17:30:02 -0600", "tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 19:50:29 -0600", @@ -107,9 +107,9 @@ "tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2025-04-22 21:37:22 -0500", "tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 15:40:30 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 15:40:30 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 17:30:02 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 17:30:02 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 17:30:02 -0600", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2025-02-10 14:50:36 -0700", @@ -123,7 +123,7 @@ "tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 15:40:30 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 17:30:02 -0600", "tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600", From 312d08f26440353127d6a58882964b087c13bc09 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 17:45:20 -0600 Subject: [PATCH 10/21] another style nit --- library/data_structures/uncommon/linear_rmq.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index 884bd532..e59f1ded 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -39,9 +39,9 @@ template struct linear_rmq { if (unsigned j = in[l] ^ in[r]; j) { j = asc[l] & asc[r] & -bit_floor(j); if (unsigned k = asc[l] ^ j; k) - k = bit_floor(k), l = head[(in[l] & -k) | k]; + k = bit_floor(k), l = head[-k & in[l] | k]; if (unsigned k = asc[r] ^ j; k) - k = bit_floor(k), r = head[(in[r] & -k) | k]; + k = bit_floor(k), r = head[-k & in[r] | k]; } return cmp(a[l], a[r]) ? l : r; } From dcfa30fe965e4425c5dda20fd908fa40db177c01 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 17:58:03 -0600 Subject: [PATCH 11/21] another golf --- library/data_structures/uncommon/linear_rmq.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index e59f1ded..80ded2c6 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -20,16 +20,16 @@ template struct linear_rmq { n(sz(a)), a(a), cmp(cmp), asc(n), in(n), head(n + 1) { vi st{-1}; rep(i, 0, n + 1) { - int prev = -1; + int prev = 0; while (sz(st) > 1 && (i == n || !cmp(a[st.back()], a[i]))) { - if (prev != -1) head[prev] = st.back(); + if (prev) head[prev] = st.back(); int b = bit_floor((end(st)[-2] + 1u) ^ i); in[st.back()] = prev = i & -b; st.pop_back(); asc[st.back() + 1] |= b; } - if (prev != -1) head[prev] = i; + if (prev) head[prev] = i; st.push_back(i); } rep(i, 1, n)(asc[i] |= asc[i - 1]) &= From c7f4999d1f14206785dde7e69c50db37a6105c89 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 18:00:05 -0600 Subject: [PATCH 12/21] another golf --- library/data_structures/uncommon/linear_rmq.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index 80ded2c6..99f1c50e 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -23,13 +23,13 @@ template struct linear_rmq { int prev = 0; while (sz(st) > 1 && (i == n || !cmp(a[st.back()], a[i]))) { - if (prev) head[prev] = st.back(); + head[prev] = st.back(); int b = bit_floor((end(st)[-2] + 1u) ^ i); in[st.back()] = prev = i & -b; st.pop_back(); asc[st.back() + 1] |= b; } - if (prev) head[prev] = i; + head[prev] = i; st.push_back(i); } rep(i, 1, n)(asc[i] |= asc[i - 1]) &= From e874bccd3213a249700e99e219659da9e3b52262 Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 4 Aug 2025 00:13:44 +0000 Subject: [PATCH 13/21] [auto-verifier] verify commit c7f4999d1f14206785dde7e69c50db37a6105c89 --- .verify-helper/timestamps.remote.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index b63e01f6..a5bc1ba8 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -33,15 +33,15 @@ "tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2025-02-11 13:53:30 -0700", "tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2025-02-10 23:30:47 -0700", -"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-08-03 17:30:02 -0600", +"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-08-03 18:00:05 -0600", "tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 17:30:02 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 17:30:02 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 18:00:05 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 18:00:05 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-21 00:23:10 -0500", @@ -78,8 +78,8 @@ "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_int.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700", -"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-08-03 17:30:02 -0600", -"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-08-03 17:30:02 -0600", +"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-08-03 18:00:05 -0600", +"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-08-03 18:00:05 -0600", "tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 19:50:29 -0600", @@ -107,9 +107,9 @@ "tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2025-04-22 21:37:22 -0500", "tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 17:30:02 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 17:30:02 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 17:30:02 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 18:00:05 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 18:00:05 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 18:00:05 -0600", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2025-02-10 14:50:36 -0700", @@ -123,7 +123,7 @@ "tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 17:30:02 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 18:00:05 -0600", "tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600", From 321f46d35cb371b03a3bc79997e5b3ebb0700024 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 18:14:28 -0600 Subject: [PATCH 14/21] will hopefully fix the warning --- library/data_structures/uncommon/linear_rmq.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index 99f1c50e..bb7ffd05 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -39,9 +39,9 @@ template struct linear_rmq { if (unsigned j = in[l] ^ in[r]; j) { j = asc[l] & asc[r] & -bit_floor(j); if (unsigned k = asc[l] ^ j; k) - k = bit_floor(k), l = head[-k & in[l] | k]; + k = bit_floor(k), l = head[k | in[l] & -k]; if (unsigned k = asc[r] ^ j; k) - k = bit_floor(k), r = head[-k & in[r] | k]; + k = bit_floor(k), r = head[k | in[r] & -k]; } return cmp(a[l], a[r]) ? l : r; } From 822e46ae60c7783dcb402394c873945ef9cdad6a Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 18:17:06 -0600 Subject: [PATCH 15/21] revert to fix warning --- library/data_structures/uncommon/linear_rmq.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index bb7ffd05..072015f6 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -39,9 +39,9 @@ template struct linear_rmq { if (unsigned j = in[l] ^ in[r]; j) { j = asc[l] & asc[r] & -bit_floor(j); if (unsigned k = asc[l] ^ j; k) - k = bit_floor(k), l = head[k | in[l] & -k]; + k = bit_floor(k), l = head[(in[l] & -k) | k]; if (unsigned k = asc[r] ^ j; k) - k = bit_floor(k), r = head[k | in[r] & -k]; + k = bit_floor(k), r = head[(in[r] & -k) | k]; } return cmp(a[l], a[r]) ? l : r; } From e41d2e35ae31296eaa9b6a13a6bc0d204a225909 Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 4 Aug 2025 00:31:09 +0000 Subject: [PATCH 16/21] [auto-verifier] verify commit 822e46ae60c7783dcb402394c873945ef9cdad6a --- .verify-helper/timestamps.remote.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index a5bc1ba8..e9b3d3c2 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -33,15 +33,15 @@ "tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2025-02-11 13:53:30 -0700", "tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2025-02-10 23:30:47 -0700", -"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-08-03 18:00:05 -0600", +"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-08-03 18:17:06 -0600", "tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 18:00:05 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 18:00:05 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 18:17:06 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 18:17:06 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-21 00:23:10 -0500", @@ -78,8 +78,8 @@ "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_int.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700", -"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-08-03 18:00:05 -0600", -"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-08-03 18:00:05 -0600", +"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-08-03 18:17:06 -0600", +"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-08-03 18:17:06 -0600", "tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 19:50:29 -0600", @@ -107,9 +107,9 @@ "tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2025-04-22 21:37:22 -0500", "tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 18:00:05 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 18:00:05 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 18:00:05 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 18:17:06 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 18:17:06 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 18:17:06 -0600", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2025-02-10 14:50:36 -0700", @@ -123,7 +123,7 @@ "tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 18:00:05 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 18:17:06 -0600", "tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600", From 4d6a02b5d44f50599d63a6261a4968fa9cdefd43 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 18:39:58 -0600 Subject: [PATCH 17/21] nit --- library/data_structures/uncommon/linear_rmq.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index 072015f6..0847d3d2 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -15,9 +15,9 @@ template struct linear_rmq { int n; vector a; F cmp; - vi asc, in, head; + vi in, asc, head; linear_rmq(const vector& a, F cmp): - n(sz(a)), a(a), cmp(cmp), asc(n), in(n), head(n + 1) { + n(sz(a)), a(a), cmp(cmp), in(n), asc(n), head(n + 1) { vi st{-1}; rep(i, 0, n + 1) { int prev = 0; From 7d255ba4edb1aac4c028960c8c64bbc30db8923b Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 4 Aug 2025 00:53:26 +0000 Subject: [PATCH 18/21] [auto-verifier] verify commit 4d6a02b5d44f50599d63a6261a4968fa9cdefd43 --- .verify-helper/timestamps.remote.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index e9b3d3c2..b889bacf 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -33,15 +33,15 @@ "tests/library_checker_aizu_tests/data_structures/line_tree_lib_checker.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2025-02-11 13:53:30 -0700", "tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2025-02-10 23:30:47 -0700", -"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-08-03 18:17:06 -0600", +"tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2025-08-03 18:39:58 -0600", "tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/persistent_seg_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/pq_ds_undo_with_dsu.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/data_structures/range_parallel_dsu.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/data_structures/rmq_disjoint_sparse_table.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 18:17:06 -0600", -"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 18:17:06 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2025-08-03 18:39:58 -0600", +"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2025-08-03 18:39:58 -0600", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2024-12-21 00:23:10 -0500", @@ -78,8 +78,8 @@ "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_int.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700", -"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-08-03 18:17:06 -0600", -"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-08-03 18:17:06 -0600", +"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-08-03 18:39:58 -0600", +"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2025-08-03 18:39:58 -0600", "tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 19:50:29 -0600", @@ -107,9 +107,9 @@ "tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2025-04-22 21:37:22 -0500", "tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2025-02-10 23:30:47 -0700", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 18:17:06 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 18:17:06 -0600", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 18:17:06 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-08-03 18:39:58 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-08-03 18:39:58 -0600", +"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-08-03 18:39:58 -0600", "tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2025-02-10 14:50:36 -0700", @@ -123,7 +123,7 @@ "tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 18:17:06 -0600", +"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-08-03 18:39:58 -0600", "tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600", From 0084dcf62bd2141e9b6a153587e099470f667428 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 19:00:12 -0600 Subject: [PATCH 19/21] I like this way --- library/data_structures/uncommon/linear_rmq.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index 0847d3d2..8aca5af9 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -32,8 +32,8 @@ template struct linear_rmq { head[prev] = i; st.push_back(i); } - rep(i, 1, n)(asc[i] |= asc[i - 1]) &= - -(in[i] & -in[i]); + rep(i, 1, n) asc[i] = + (asc[i] | asc[i - 1]) & -(in[i] & -in[i]); } int idx(int l, int r) { // [l, r] if (unsigned j = in[l] ^ in[r]; j) { From 780363b543d963f94e5d45465ced8df8132734ae Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 19:02:48 -0600 Subject: [PATCH 20/21] more golf --- library/data_structures/uncommon/linear_rmq.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index 8aca5af9..ab5314f2 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -24,13 +24,12 @@ template struct linear_rmq { while (sz(st) > 1 && (i == n || !cmp(a[st.back()], a[i]))) { head[prev] = st.back(); - int b = bit_floor((end(st)[-2] + 1u) ^ i); + auto k = end(st)[-2] + 1u, b = bit_floor(k ^ i); in[st.back()] = prev = i & -b; + asc[k] |= b; st.pop_back(); - asc[st.back() + 1] |= b; } - head[prev] = i; - st.push_back(i); + st.push_back(head[prev] = i); } rep(i, 1, n) asc[i] = (asc[i] | asc[i - 1]) & -(in[i] & -in[i]); From 9717342c17cee967eba4e89ff7ba5a53d6c2705d Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 3 Aug 2025 19:03:21 -0600 Subject: [PATCH 21/21] more golf --- library/data_structures/uncommon/linear_rmq.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/data_structures/uncommon/linear_rmq.hpp b/library/data_structures/uncommon/linear_rmq.hpp index ab5314f2..d7f05ea3 100644 --- a/library/data_structures/uncommon/linear_rmq.hpp +++ b/library/data_structures/uncommon/linear_rmq.hpp @@ -25,8 +25,7 @@ template struct linear_rmq { (i == n || !cmp(a[st.back()], a[i]))) { head[prev] = st.back(); auto k = end(st)[-2] + 1u, b = bit_floor(k ^ i); - in[st.back()] = prev = i & -b; - asc[k] |= b; + in[st.back()] = prev = i & -b, asc[k] |= b; st.pop_back(); } st.push_back(head[prev] = i);