結果

問題 No.2395 区間二次変換一点取得
ユーザー Cyanmond
提出日時 2023-07-28 21:51:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 313 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 199,536 KB
最終ジャッジ日時 2025-02-15 20:17:23
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include "atcoder/modint"

using i64 = long long;
// using Fp = atcoder::modint998244353;

#include "atcoder/lazysegtree"

int op(int a, int b) {
    return a + b;
}
int e() {
    return 0;
}

int main() {
    int N, Q;
    i64 B;
    std::cin >> N >> B >> Q;
    std::vector<i64> X(Q + 1), Y(Q + 1), Z(Q + 1);
    X[0] = Y[0] = Z[0] = 1;
    for (int i = 0; i < Q; ++i) {
        X[i + 1] = X[i] + 1;
        Y[i + 1] = 3 * Y[i] + 2 * X[i + 1] * Z[i];
        Z[i + 1] = 3 * Z[i];
        X[i + 1] %= B;
        Y[i + 1] %= B;
        Z[i + 1] %= B;
    }
    atcoder::lazy_segtree<int, op, e, int, op, op, e> seg(N);
    while (Q--) {
        int l, r, m;
        std::cin >> l >> m >> r;
        --l, --m;
        seg.apply(l, r, 1);
        const auto i = seg.get(m);
        std::cout << X[i] << ' ' << Y[i] << ' ' << Z[i] << std::endl;
    }
}
0