1
0
Fork 0

Update trees/segtree_generic.cc

Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
subcrip 2024-05-30 20:30:10 +08:00
parent 52bc203f6a
commit 4a2403a1dc
1 changed files with 1 additions and 3 deletions

View File

@ -1,4 +1,3 @@
template<typename Addable_Info_t, typename Tag_t, typename Sequence = std::vector<Addable_Info_t>> class segtree { template<typename Addable_Info_t, typename Tag_t, typename Sequence = std::vector<Addable_Info_t>> class segtree {
private: private:
using size_type = uint64_t; using size_type = uint64_t;
@ -27,7 +26,7 @@ private:
if (s != t) push(p, m - s + 1, t - m); if (s != t) push(p, m - s + 1, t - m);
if (x <= m) set(s, m, p * 2, x, c); if (x <= m) set(s, m, p * 2, x, c);
else set(m + 1, t, p * 2 + 1, x, c); else set(m + 1, t, p * 2 + 1, x, c);
d[p] = d[p * 2] + d[p * 2 + 1]; pull(p);
} }
void range_apply(size_type s, size_type t, size_type p, size_type l, size_type r, const tag_type& c) { void range_apply(size_type s, size_type t, size_type p, size_type l, size_type r, const tag_type& c) {
@ -123,4 +122,3 @@ struct Info {
Info operator+(const Info &a, const Info &b) { Info operator+(const Info &a, const Info &b) {
return {a.val + b.val}; return {a.val + b.val};
} }