結果

問題 No.1142 XOR と XOR
ユーザー yupiteru_kunyupiteru_kun
提出日時 2020-07-31 22:51:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,661 ms / 2,000 ms
コード長 1,539 bytes
コンパイル時間 2,694 ms
コンパイル使用メモリ 198,920 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:29:24
合計ジャッジ時間 27,927 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1,661 ms
6,944 KB
testcase_04 AC 1,287 ms
6,940 KB
testcase_05 AC 1,068 ms
6,944 KB
testcase_06 AC 1,346 ms
6,944 KB
testcase_07 AC 1,612 ms
6,940 KB
testcase_08 AC 1,647 ms
6,940 KB
testcase_09 AC 1,632 ms
6,940 KB
testcase_10 AC 1,620 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 874 ms
6,940 KB
testcase_15 AC 852 ms
6,940 KB
testcase_16 AC 68 ms
6,944 KB
testcase_17 AC 1,215 ms
6,940 KB
testcase_18 AC 274 ms
6,940 KB
testcase_19 AC 1,327 ms
6,940 KB
testcase_20 AC 887 ms
6,940 KB
testcase_21 AC 529 ms
6,940 KB
testcase_22 AC 295 ms
6,944 KB
testcase_23 AC 1,237 ms
6,944 KB
testcase_24 AC 1,391 ms
6,940 KB
testcase_25 AC 811 ms
6,940 KB
testcase_26 AC 1,314 ms
6,944 KB
testcase_27 AC 1,044 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>

int main() {
  long long n, m, k;
  std::cin >> n >> m >> k;
  long long aList[n];
  long long bList[m];
  for(int i = 0;i < n;++i) {
    std::cin >> aList[i];
  }
  for(int i = 0;i < m;++i) {
    std::cin >> bList[i];
  }
  long long mod = 1000000007;
  long long aCnts[1024];
  long long bCnts[1024];
  long long *aCnt, *bCnt;
  aCnt = new long long[1024];
  bCnt = new long long[1024];
  for(int i= 0;i < 1024;++i) {
    aCnt[i] = 0;
    bCnt[i] = 0;
    aCnts[i] = 0;
    bCnts[i] = 0;
  }
  for(int i = 0;i < n;++i) {
    long long nextACnt[1024];
    for(int j = 0;j < 1024;++j) {
      nextACnt[j] = 0;
    }
    for(int j = 0;j < 1024;++j) {
      nextACnt[j ^ aList[i]] += aCnt[j];
    }
    nextACnt[aList[i]]++;
    for(int j = 0;j < 1024;++j) {
      aCnt[j] = nextACnt[j] % mod;
    }
    for(int j = 0;j < 1024;++j) {
      aCnts[j] += aCnt[j];
      aCnts[j] %= mod;
    }
  }
  for(int i = 0;i < m;++i) {
    long long nextBCnt[1024];
    for(int j = 0;j < 1024;++j) {
      nextBCnt[j] = 0;
    }
    for(int j = 0;j < 1024;++j) {
      nextBCnt[j ^ bList[i]] += bCnt[j];
    }
    nextBCnt[bList[i]]++;
    for(int j = 0;j < 1024;++j) {
      bCnt[j] = nextBCnt[j] % mod;
    }
    for(int j = 0;j < 1024;++j) {
      bCnts[j] += bCnt[j];
      bCnts[j] %= mod;
    }
  }
  long long ans = 0;
  for(int i = 0;i < 1024;++i) {
    ans += aCnts[i] * bCnts[k ^ i];
    ans %= mod;
  }
  std::cout << ans << std::endl;
  return 0;
}

0