結果

問題 No.2265 Xor Range Substring Sum Query
ユーザー とりゐとりゐ
提出日時 2023-03-09 17:35:35
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,522 bytes
コンパイル時間 2,497 ms
コンパイル使用メモリ 160,188 KB
実行使用メモリ 7,084 KB
最終ジャッジ日時 2023-10-25 05:04:01
合計ジャッジ時間 6,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
#define elif else if
 
using mint=atcoder::modint998244353;
mint pow11[1<<17];
mint pow2[1<<17];
mint node[9][1<<16];

mint calc(mint fL,int Lsize,mint fR,int Rsize){
  return fL*pow11[Rsize]+fR*pow2[Lsize];
}

void merge(int i,int j){
  int L=j;
  int R=L^(1<<(i-1));
  node[i][L]=calc(node[i-1][L],1<<(i-1),node[i-1][R],1<<(i-1));
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  int N=1<<n;
  int m=n/2;
  string S;
  cin>>S;

  for(int i=0;i<N;i++){
    node[0][i]=S[i]-'0';
  }

  pow11[0]=1;
  pow2[0]=1;
  for(int i=1;i<=N;i++){
    pow11[i]=pow11[i-1]*11;
    pow2[i]=pow2[i-1]*2;
  }
  
  for(int i=0;i<m;i++){
    for(int j=0;j<N;j++){
      merge(i+1,j);
    }
  }

  int q,t,x,y,L,R,X,s,l,r;
  cin>>q;
  for(int tc=0;tc<q;tc++){
    cin>>t;
    if(t==1){
      cin>>x>>y;
      node[0][x]=y;
      for(int i=0;i<m;i++){
        s=1<<(i+1);
        l=(x/s)*s;
        r=l+s;
        for(int j=l;j<r;j++){
          merge(i+1,j);
        }
      }
    }
    else{
      cin>>L>>R>>X;
      R++;
      mint res=0;
      int size=0;

      s=(1<<m);
      while(L<R&&L%s!=0){
        res=calc(res,size,node[0][L^X],1);
        L+=1;
        size+=1;
      }

      while(L+s<=R){
        res=calc(res,size,node[m][L^X],s);
        L+=s;
        size+=s;
      }

      while(L<R){
        res=calc(res,size,node[0][L^X],1);
        L+=1;
        size+=1;
      }

      cout<<res.val()<<'\n';
    }
  }
}
0