We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0084dcf commit 780363bCopy full SHA for 780363b
library/data_structures/uncommon/linear_rmq.hpp
@@ -24,13 +24,12 @@ template<class T, class F> struct linear_rmq {
24
while (sz(st) > 1 &&
25
(i == n || !cmp(a[st.back()], a[i]))) {
26
head[prev] = st.back();
27
- int b = bit_floor((end(st)[-2] + 1u) ^ i);
+ auto k = end(st)[-2] + 1u, b = bit_floor(k ^ i);
28
in[st.back()] = prev = i & -b;
29
+ asc[k] |= b;
30
st.pop_back();
- asc[st.back() + 1] |= b;
31
}
32
- head[prev] = i;
33
- st.push_back(i);
+ st.push_back(head[prev] = i);
34
35
rep(i, 1, n) asc[i] =
36
(asc[i] | asc[i - 1]) & -(in[i] & -in[i]);
0 commit comments