Open Astral-23 opened 2 months ago
range affine range sum
struct S {
ll s;
ll sz;
};
S op(S l, S r) { return S{l.s + r.s, l.sz + r.sz}; }
S e() { return S{0, 0}; }
struct F {
ll a, b;
};
S mapping(F f, S s) {
S res;
res.s = f.a * s.s + f.b * s.sz;
res.sz = s.sz;
return res;
}
F composition(F l, F r) { return F{l.a * r.a, l.a * r.b + l.b}; }
F id() { return F{1, 0}; }
using segtree = lazysegtree<S, op, e, F, mapping, composition, id>;
区間代入/区間sum
https://atcoder.jp/contests/abc371/submissions/57776675
区間代入/ min . max. sum
https://atcoder.jp/contests/abc371/submissions/58548762