結果

問題 No.1142 XOR と XOR
ユーザー iqueue02iqueue02
提出日時 2020-07-31 23:20:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 668 ms / 2,000 ms
コード長 1,810 bytes
コンパイル時間 2,223 ms
コンパイル使用メモリ 198,788 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 16:31:23
合計ジャッジ時間 12,484 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 668 ms
6,940 KB
testcase_04 AC 476 ms
6,940 KB
testcase_05 AC 393 ms
6,944 KB
testcase_06 AC 494 ms
6,944 KB
testcase_07 AC 654 ms
6,944 KB
testcase_08 AC 604 ms
6,944 KB
testcase_09 AC 603 ms
6,940 KB
testcase_10 AC 605 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 342 ms
6,940 KB
testcase_15 AC 331 ms
6,944 KB
testcase_16 AC 28 ms
6,944 KB
testcase_17 AC 500 ms
6,944 KB
testcase_18 AC 110 ms
6,940 KB
testcase_19 AC 490 ms
6,944 KB
testcase_20 AC 313 ms
6,944 KB
testcase_21 AC 194 ms
6,944 KB
testcase_22 AC 109 ms
6,940 KB
testcase_23 AC 457 ms
6,948 KB
testcase_24 AC 516 ms
6,940 KB
testcase_25 AC 318 ms
6,940 KB
testcase_26 AC 517 ms
6,944 KB
testcase_27 AC 414 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef unsigned long long ll;
typedef long double ld;
typedef pair<int,int> P;

constexpr int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  vector<mint> tmp1(1 << 10, 0), cnt1(1 << 10, 0);

  int cur = 0;
  for (int i = 0; i < n; i++) {
    tmp1[cur] += 1;
    cur ^= a[i];
    for (int j = 0; j < (1 << 10); j++) cnt1[cur ^ j] += tmp1[j];
  }

  vector<mint> tmp2(1 << 10, 0), cnt2(1 << 10, 0);
  cur = 0;
  for (int i = 0; i < m; i++) {
    tmp2[cur] += 1;
    cur ^= b[i];
    for (int j = 0; j < (1 << 10); j++) cnt2[cur ^ j] += tmp2[j];
  }

  mint res = 0;

  for (int i = 0; i < (1 << 10); i++) {
    int j = i ^ k;
    res += cnt1[i] * cnt2[j];
  }
  cout << res.x << endl;
  return 0;
} 
0