This documentation is automatically generated by online-judge-tools/verification-helper
#include "algebra/range_assign_range_sum.hpp"lazy_segtree<range_assign_range_sum<T>> のように使う。S = {T sum; int len}, F = std::optional<T>
from(v): 値 v 1 個分の要素 {v, 1} を返す。初期化や一点更新ではこれで S を作る。apply(l, r, v) で a[l], ..., a[r - 1] を v にする。prod(l, r).sum が区間和。#pragma once
#include <optional>
template <class T>
struct range_assign_range_sum {
struct S {
T sum;
int len;
};
using F = std::optional<T>;
static S op(S a, S b) {
return {a.sum + b.sum, a.len + b.len};
}
static S e() {
return {T(0), 0};
}
static S mapping(F f, S x) {
return f ? S{*f * x.len, x.len} : x;
}
static F composition(F f, F g) {
return f ? f : g;
}
static F id() {
return std::nullopt;
}
static constexpr bool composition_commutative = false;
static S from(T v) {
return {v, 1};
}
};#line 2 "algebra/range_assign_range_sum.hpp"
#include <optional>
template <class T>
struct range_assign_range_sum {
struct S {
T sum;
int len;
};
using F = std::optional<T>;
static S op(S a, S b) {
return {a.sum + b.sum, a.len + b.len};
}
static S e() {
return {T(0), 0};
}
static S mapping(F f, S x) {
return f ? S{*f * x.len, x.len} : x;
}
static F composition(F f, F g) {
return f ? f : g;
}
static F id() {
return std::nullopt;
}
static constexpr bool composition_commutative = false;
static S from(T v) {
return {v, 1};
}
};