結果

問題 No.1891 Static Xor Range Composite Query
ユーザー nononnonon
提出日時 2024-04-08 10:02:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 361 ms / 5,000 ms
コード長 1,488 bytes
コンパイル時間 7,443 ms
コンパイル使用メモリ 211,372 KB
実行使用メモリ 46,336 KB
最終ジャッジ日時 2024-04-08 10:03:14
合計ジャッジ時間 19,764 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 28 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 25 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 5 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 3 ms
6,676 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 5 ms
6,676 KB
testcase_18 AC 3 ms
6,676 KB
testcase_19 AC 3 ms
6,676 KB
testcase_20 AC 3 ms
6,676 KB
testcase_21 AC 345 ms
46,336 KB
testcase_22 AC 342 ms
46,336 KB
testcase_23 AC 359 ms
46,336 KB
testcase_24 AC 343 ms
46,336 KB
testcase_25 AC 342 ms
46,336 KB
testcase_26 AC 343 ms
46,336 KB
testcase_27 AC 343 ms
46,336 KB
testcase_28 AC 341 ms
46,336 KB
testcase_29 AC 342 ms
46,336 KB
testcase_30 AC 361 ms
46,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
template<typename S, auto op, auto e>
struct static_xor_segtree
{
    static_xor_segtree():static_xor_segtree(0){}
    static_xor_segtree(int n_):static_xor_segtree(vector<S>(n_,e())){}
    static_xor_segtree(const vector<S>&v):n((int)v.size())
    {
        log=0;
        while((1<<log)<n)log++;
        sz=1<<log;
        node.assign(log+1,vector<S>(sz,e()));
        for(int i=0;i<n;i++)node[0][i]=v[i];
        for(int i=0;i<log;i++)for(int j=0;j<n;j++)update(i,j);
    }
    S prod(int l, int r, int x)
    {
        S pl=e(),pr=e();
        int d=0;
        while(l<r)
        {
            if(l&1)pl=op(pl,node[d][((l++)<<d)^x]);
            if(r&1)pr=op(node[d][((--r)<<d)^x],pr);
            l>>=1,r>>=1,d++;
        }
        return op(pl,pr);
    }
private:
    int n,log,sz;
    vector<vector<S>>node;
    void update(int i, int j){node[i+1][j]=op(node[i][j],node[i][j^(1<<i)]);}
};
struct F{mint a,b;};
F op(F f, F g){return F{f.a*g.a,f.b*g.a+g.b};}
F e(){return F{1,0};}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,Q;
    cin>>N>>Q;
    vector<F>Fs(N);
    for(int i=0;i<N;i++)
    {
        int a,b;
        cin>>a>>b;
        Fs[i]=F{a,b};
    }
    static_xor_segtree<F,op,e>seg(Fs);
    while(Q--)
    {
        int l,r,p,x;
        cin>>l>>r>>p>>x;
        auto f=seg.prod(l,r,p);
        cout<<(f.a*x+f.b).val()<<'\n';
    }
}
0