import std.algorithm : max; ///区間max, 区間加算 auto seg = LazySeg!(int, int, (a, b) => max(a, b), (a, b) => a+b, (a, b) => a+b, 0, 0)([2, 1, 4]); //[2, 1, 4] seg[0] = 2; seg[1] = 1; seg[2] = 4; assert(seg[0..3].sum == 4); //[2, 1, 5] seg[2] = 5; assert(seg[0..2].sum == 2); assert(seg[0..3].sum == 5); //[12, 11, 5] seg[0..2] += 10; assert(seg[0..3].sum == 12);
遅延伝搬SegTree
T型の配列aに対して、al..r += x(xはL型)、opTT(al..r)が高速に計算できる