結果

問題 No.2395 区間二次変換一点取得
ユーザー 👑 獅子座じゃない人獅子座じゃない人
提出日時 2023-07-28 23:12:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 172,668 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2024-04-16 07:09:15
合計ジャッジ時間 6,032 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 33 ms
5,376 KB
testcase_13 AC 350 ms
5,760 KB
testcase_14 AC 340 ms
5,888 KB
testcase_15 AC 343 ms
5,760 KB
testcase_16 AC 340 ms
5,632 KB
testcase_17 AC 344 ms
5,760 KB
testcase_18 AC 294 ms
5,632 KB
testcase_19 AC 292 ms
5,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#include "atcoder/modint"
#include "atcoder/lazysegtree"
using namespace atcoder;
using mint=modint;

using S=int;
using F=pair<int,int>;
S op(S a, S b){
    return a+b;
}
S e(){
    return 0;
}
S mapping(F f, S x){
    return f.first*x+f.second;
}
F composition(F f, F g){
    return make_pair(f.first*g.first,f.first*g.second+f.second);
}
F id(){
    return make_pair(1,0);
}

int main(void) {
    int n,b,q;
    cin >> n >> b >> q;
    mint::set_mod(b);
    vector<S> v(n,1);
    lazy_segtree<S,op,e,F,mapping,composition,id> s(v);
    while(q--){
        int l,m,r;
        cin >> l >> m >> r;
        --l;
        --m;
        --r;
        s.apply(l,r+1,make_pair(1,1));
        auto ans=s.get(m);
        cout << mint(ans).val() << " " << (mint(3).pow(ans-2)*(mint(ans)*ans+ans+1)).val() << " " << (mint(3).pow(ans-1)).val() << endl;
    }
    return 0;
}
0