Skip to content

Commit 278d085

Browse files
committed
fixes
1 parent 9e9d539 commit 278d085

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

library/data_structures/uncommon/linear_rmq.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ template<class T, class F> struct linear_rmq {
2424
while (st.back() != -1 &&
2525
(i == n || !cmp(a[st.back()], a[i]))) {
2626
if (prev != -1) head[prev] = st.back();
27-
int pw2 = bit_floor((end(st)[-2] + 1u) ^ i);
28-
in[st.back()] = prev = i & -pw2;
27+
int b = bit_floor((end(st)[-2] + 1u) ^ i);
28+
in[st.back()] = prev = i & -b;
2929
st.pop_back();
30-
asc[st.back() + 1] |= pw2;
30+
asc[st.back() + 1] |= b;
3131
}
3232
if (prev != -1) head[prev] = i;
3333
st.push_back(i);
3434
}
35-
rep(i, 1, n) asc[i] =
36-
(asc[i] | asc[i - 1]) & -(in[i] & -in[i]);
35+
rep(i, 1, n)(asc[i] |= asc[i - 1]) &=
36+
-(in[i] & -in[i]);
3737
}
3838
int idx(int l, int r) { // [l, r]
3939
if (unsigned j = in[l] ^ in[r]; j) {

library/data_structures/uncommon/permutation_tree.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ struct perm_tree {
3737
linear_rmq rmq_min(a_inv, less());
3838
linear_rmq rmq_max(a_inv, greater());
3939
rep(i, 1, n) {
40-
mn_i[i] = a_inv[rmq_min.query_idx(a[i - 1], a[i])];
41-
mx_i[i] = a_inv[rmq_max.query_idx(a[i - 1], a[i])];
40+
mn_i[i] = a_inv[rmq_min.idx(a[i - 1], a[i])];
41+
mx_i[i] = a_inv[rmq_max.idx(a[i - 1], a[i])];
4242
}
4343
}
4444
rep(i, 0, n) allocate(i, a[i], 1, 0, {});

tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void test_all_subarrays(const vector<int>& a) {
1313
linear_rmq lin_rmq(a, less());
1414
for (int l = 0; l < n; l++) {
1515
for (int r = l + 1; r <= n; r++) {
16-
int idx_min = lin_rmq.query_idx(l, r - 1);
16+
int idx_min = lin_rmq.idx(l, r - 1);
1717
assert(l <= idx_min && idx_min < r);
1818
assert(a[idx_min] == rmq.query(l, r));
1919
assert(a[idx_min] == dis_rmq.query(l, r));

0 commit comments

Comments
 (0)