結果

問題 No.1142 XOR と XOR
ユーザー SSRSSSRS
提出日時 2020-07-31 21:42:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 875 ms / 2,000 ms
コード長 1,068 bytes
コンパイル時間 1,463 ms
コンパイル使用メモリ 168,284 KB
実行使用メモリ 6,260 KB
最終ジャッジ日時 2023-08-07 21:56:13
合計ジャッジ時間 15,319 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 875 ms
6,148 KB
testcase_04 AC 678 ms
5,632 KB
testcase_05 AC 556 ms
5,184 KB
testcase_06 AC 702 ms
5,932 KB
testcase_07 AC 839 ms
6,260 KB
testcase_08 AC 860 ms
6,256 KB
testcase_09 AC 858 ms
6,244 KB
testcase_10 AC 859 ms
6,192 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 457 ms
4,740 KB
testcase_15 AC 445 ms
4,696 KB
testcase_16 AC 38 ms
4,376 KB
testcase_17 AC 629 ms
5,392 KB
testcase_18 AC 141 ms
4,376 KB
testcase_19 AC 695 ms
5,580 KB
testcase_20 AC 447 ms
4,672 KB
testcase_21 AC 276 ms
4,380 KB
testcase_22 AC 155 ms
4,376 KB
testcase_23 AC 647 ms
5,308 KB
testcase_24 AC 734 ms
5,732 KB
testcase_25 AC 423 ms
4,552 KB
testcase_26 AC 690 ms
5,620 KB
testcase_27 AC 552 ms
5,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<int> b(M);
  for (int i = 0; i < M; i++){
    cin >> b[i];
  }
  vector<int> sa(N + 1);
  sa[0] = 0;
  for (int i = 0; i < N; i++){
    sa[i + 1] = sa[i] ^ a[i];
  }
  vector<int> sb(M + 1);
  sb[0] = 0;
  for (int i = 0; i < M; i++){
    sb[i + 1] = sb[i] ^ b[i];
  }
  vector<int> cnt1(1024, 0);
  vector<long long> cnt2(1024, 0);
  for (int i = 0; i <= N; i++){
    for (int j = 0; j < 1024; j++){
      cnt2[j ^ sa[i]] += cnt1[j];
      cnt2[j ^ sa[i]] %= MOD;
    }
    cnt1[sa[i]]++;
  }
  vector<int> cnt3(1024, 0);
  vector<long long> cnt4(1024, 0);
  for (int i = 0; i <= M; i++){
    for (int j = 0; j < 1024; j++){
      cnt4[j ^ sb[i]] += cnt3[j];
      cnt4[j ^ sb[i]] %= MOD;
    }
    cnt3[sb[i]]++;
  }
  long long ans = 0;
  for (int i = 0; i < 1024; i++){
    ans += cnt2[i] * cnt4[i ^ K] % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
0