Skip to content

Commit c098574

Browse files
committed
more changes
1 parent 4f2e9e7 commit c098574

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

library/data_structures_inclusive_inclusive/lazy_seg_tree.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#pragma once
2-
#include "lazy_seg_tree_inc_midpoint.hpp"
3-
ll op_inc(ll vl, ll vr) { return vl + vr; }
4-
struct seg_tree_inc {
2+
#include "seg_tree_midpoint.hpp"
3+
ll op(ll vl, ll vr) { return vl + vr; }
4+
struct seg_tree {
55
int n;
66
vector<ll> tree, lazy;
7-
seg_tree_inc(int n): n(n), tree(2 * n), lazy(n) {}
8-
seg_tree_inc(const vi& a):
7+
seg_tree(int n): n(n), tree(2 * n), lazy(n) {}
8+
seg_tree(const vi& a):
99
n(sz(a)), tree(2 * n), lazy(n) {
1010
int pw2 = bit_ceil(size(a));
1111
rep(i, 0, n) tree[(i + pw2) % n + n] = a[i];
1212
for (int i = n - 1; i >= 1; i--)
13-
tree[i] = op_inc(tree[2 * i], tree[2 * i + 1]);
13+
tree[i] = op(tree[2 * i], tree[2 * i + 1]);
1414
}
1515
void apply(ll change, int tl, int tr, int v) {
1616
tree[v] += (tr - tl + 1) * change;
@@ -31,21 +31,21 @@ struct seg_tree_inc {
3131
if (r < tl || tr < l) return;
3232
if (l <= tl && tr <= r)
3333
return apply(change, tl, tr, v);
34-
int tm = split_inc(tl, tr);
34+
int tm = split(tl, tr);
3535
push(tl, tm, tr, v);
3636
update_impl(l, r, change, tl, tm, 2 * v);
3737
update_impl(l, r, change, tm + 1, tr, 2 * v + 1);
38-
tree[v] = op_inc(tree[2 * v], tree[2 * v + 1]);
38+
tree[v] = op(tree[2 * v], tree[2 * v + 1]);
3939
}
4040
ll query(int l, int r) { // [l, r]
4141
return query_impl(l, r, 0, n - 1, 1);
4242
}
4343
ll query_impl(int l, int r, int tl, int tr, int v) {
4444
if (r < tl || tr < l) return 0;
4545
if (l <= tl && tr <= r) return tree[v];
46-
int tm = split_inc(tl, tr);
46+
int tm = split(tl, tr);
4747
push(tl, tm, tr, v);
48-
return op_inc(query_impl(l, r, tl, tm, 2 * v),
48+
return op(query_impl(l, r, tl, tm, 2 * v),
4949
query_impl(l, r, tm + 1, tr, 2 * v + 1));
5050
}
5151
};

library/data_structures_inclusive_inclusive/rmq.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#pragma once
22
//! @code
3-
//! rmq_inc rmq1(a, ranges::min);
4-
//! rmq_inc rmq2(a, [&](auto& x, auto& y) {
3+
//! RMQ rmq1(a, ranges::min);
4+
//! RMQ rmq2(a, [&](auto& x, auto& y) {
55
//! return min(x, y);
66
//! });
7-
//! vector<rmq_inc<int, function<int(int, int)>>>
7+
//! vector<RMQ<int, function<int(int, int)>>>
88
//! rmqs(3, {{}, NULL});
99
//! rmqs[1] = {a, ranges::min};
1010
//! @endcode
1111
//! @time O(nlogn + q)
1212
//! @space O(nlogn)
13-
template<class T, class F> struct rmq_inc {
13+
// NOLINTNEXTLINE(readability-identifier-naming)
14+
template<class T, class F> struct RMQ {
1415
vector<vector<T>> dp;
1516
F op;
16-
rmq_inc(const vector<T>& a, F op): dp(1, a), op(op) {
17+
RMQ(const vector<T>& a, F op): dp(1, a), op(op) {
1718
for (int i = 0; (2 << i) <= sz(a); i++) {
1819
dp.emplace_back(sz(a) - (2 << i) + 1);
1920
ranges::transform(dp[i], dp[i] | views::drop(1 << i),

library/data_structures_inclusive_inclusive/seg_tree.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
//! https://codeforces.com/blog/entry/118682
33
//! @code
44
//! {
5-
//! tree_inc st(n, pii{}, [&](pii& l, pii& r) {
5+
//! tree st(n, pii{}, [&](pii& l, pii& r) {
66
//! return min(l, r);
77
//! });
88
//! }
9-
//! tree_inc st(n, int{}, ranges::min);
9+
//! tree st(n, int{}, ranges::min);
1010
//! rep(i, 0, n) st.update(i, a[i]);
1111
//! @endcode
1212
//! @time O(n + q log n)
@@ -15,11 +15,11 @@ int nxt(int& l, int r) {
1515
int lg = __lg(min(l & -l, r - l + 1));
1616
return exchange(l, l + (1 << lg)) >> lg;
1717
}
18-
template<class T, class F> struct tree_inc {
18+
template<class T, class F> struct tree {
1919
int n;
2020
F op;
2121
vector<T> s;
22-
tree_inc(int n, T, F op): n(n), op(op), s(2 * n) {}
22+
tree(int n, T, F op): n(n), op(op), s(2 * n) {}
2323
void update(int i, T val) {
2424
for (s[i += n] = val; i /= 2;)
2525
s[i] = op(s[2 * i], s[2 * i + 1]);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#pragma once
22
//! https://codeforces.com/blog/entry/112755
33
//! @code
4-
//! int tm = split_inc(tl, tr);
4+
//! int tm = split(tl, tr);
55
//! // [tl,tr] splits into [tl,tm] and [tm+1,tr]
66
//! @endcode
7-
int split_inc(int tl, int tr) {
7+
int split(int tl, int tr) {
88
int pw2 = 1 << __lg(tr - tl + 1);
99
return min(tl + pw2 - 1, tr - pw2 / 2);
1010
}

library/data_structures_inclusive_exclusive/uncommon/binary_trie.hpp renamed to library/strings/binary_trie.hpp

File renamed without changes.

0 commit comments

Comments
 (0)