結果

問題 No.2265 Xor Range Substring Sum Query
ユーザー SSRSSSRS
提出日時 2023-04-04 19:44:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 788 bytes
コンパイル時間 1,589 ms
コンパイル使用メモリ 167,788 KB
実行使用メモリ 10,644 KB
最終ジャッジ日時 2024-04-08 18:59:28
合計ジャッジ時間 8,702 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
struct node{
  long long x, p2, p11;
  node(): x(0), p2(1), p11(1){
  }
  node(int x): x(x), p2(2), p11(11){
  }
};
node op(node L, node R){
  node ans;
  ans.x = (L.x * R.p11 + L.p2 * R.x) % MOD;
  ans.p2 = L.p2 * R.p2 % MOD;
  ans.p11 = L.p11 * R.p11 % MOD;
  return ans;
}
int main(){
  int n;
  cin >> n;
  string S;
  cin >> S;
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++){
    int t;
    cin >> t;
    if (t == 1){
      int x, y;
      cin >> x >> y;
      S[x] = '0' + y;
    }
    if (t == 2){
      int L, R, X;
      cin >> L >> R >> X;
      R++;
      node ans;
      for (int j = L; j < R; j++){
        ans = op(ans, node(S[j ^ X] - '0'));
      }
      cout << ans.x << endl;
    }
  }
}
0