algo — C++23 日本語リファレンス GitHub

test/yosupo/data_structure/point_set_range_composite_large_array.test.cpp

AC · 最終更新 2026-10-23 · GitHub

問題: https://judge.yosupo.jp/problem/point_set_range_composite_large_array

依存するヘッダ(5)
実装
// competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/point_set_range_composite_large_array
#include <iostream>
#include "number_theory/modint.hpp"
#include "segtree/dynamic_segment_tree.hpp"

using Mint = modint998;

int main(void) {
    int n, q;
    std::cin >> n >> q;
    DynamicSegmentTree<Affine<Mint>> dst(n);
    while (q--) {
        int t;
        std::cin >> t;
        if (t == 0) {
            int p, c, d;
            std::cin >> p >> c >> d;
            dst.set(p, {c, d});
        } else {
            int l, r, x;
            std::cin >> l >> r >> x;
            auto [c, d] = dst.prod(l, r);
            std::cout << c * x + d << '\n';
        }
    }

    return 0;
}