結果

問題 No.2395 区間二次変換一点取得
ユーザー ShirotsumeShirotsume
提出日時 2023-07-28 22:00:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 936 bytes
コンパイル時間 5,246 ms
コンパイル使用メモリ 263,488 KB
実行使用メモリ 31,304 KB
最終ジャッジ日時 2024-04-16 05:55:38
合計ジャッジ時間 11,302 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 31 ms
6,944 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using S = vector<long long>;
using F = long long;
int mod = 998244353;
S op(S a, S b){ return a;}
S e(){ return {1, 1, 1}; }
S mapping(F f, S x){
    for(int i = 0; i < f; i++){
      long long a, b, c;
        a = x[0];b = x[1]; c = x[2];
        x = {(a + 1) % mod, (3 * b + 2 * (a + 1) * c) % mod, 3 * c % mod};
    }
  	return x;
}
F composition(F f, F g){ return f + g;}
F id(){ return 0; }

int main(){
    int N, Q;
    cin >> N >> mod >> Q;
    vector<S> v(N);
    for(int i = 0; i < N; i++){
        v[i] = {1, 1, 1};
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);

    for(int i = 0; i < Q; i++){
        int l, m, r;
        cin >> l >> m >> r;
        l--;
        seg.apply(l, r, 1);
        vector<long long> ans = seg.get(m - 1);
        cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << '\n';
    }
}
0