結果

問題 No.1142 XOR と XOR
ユーザー ryochansqryochansq
提出日時 2020-08-10 18:34:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 2,328 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 203,196 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:41:36
合計ジャッジ時間 4,464 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,816 KB
testcase_01 AC 6 ms
6,940 KB
testcase_02 AC 6 ms
6,944 KB
testcase_03 AC 105 ms
6,944 KB
testcase_04 AC 71 ms
6,944 KB
testcase_05 AC 58 ms
6,944 KB
testcase_06 AC 71 ms
6,944 KB
testcase_07 AC 64 ms
6,944 KB
testcase_08 AC 87 ms
6,940 KB
testcase_09 AC 88 ms
6,940 KB
testcase_10 AC 88 ms
6,940 KB
testcase_11 AC 6 ms
6,944 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 5 ms
6,944 KB
testcase_14 AC 49 ms
6,940 KB
testcase_15 AC 47 ms
6,940 KB
testcase_16 AC 9 ms
6,940 KB
testcase_17 AC 50 ms
6,940 KB
testcase_18 AC 15 ms
6,944 KB
testcase_19 AC 72 ms
6,944 KB
testcase_20 AC 48 ms
6,940 KB
testcase_21 AC 31 ms
6,940 KB
testcase_22 AC 20 ms
6,940 KB
testcase_23 AC 67 ms
6,940 KB
testcase_24 AC 76 ms
6,944 KB
testcase_25 AC 46 ms
6,940 KB
testcase_26 AC 72 ms
6,944 KB
testcase_27 AC 58 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
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; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  vl a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  vl ax(1024, 0), bx(1024, 0);
  ax[0]++;
  bx[0]++;
  ll t = 0;
  rep(i, n) {
    t ^= a[i];
    ax[t]++;
  }
  t = 0;
  rep(i, m) {
    t ^= b[i];
    bx[t]++;
  }
  vector<mint> ac(1024, 0), bc(1024, 0);
  rep(i, 1024) rep2(j, i, 1024) {
    if(i == j)
      ac[0] += ax[i] * (ax[i] - 1) / 2;
    else
      ac[i ^ j] += ax[i] * ax[j];
  }
  rep(i, 1024) rep2(j, i, 1024) {
    if(i == j)
      bc[0] += bx[i] * (bx[i] - 1) / 2;
    else
      bc[i ^ j] += bx[i] * bx[j];
  }
  mint ans = 0;
  rep(i, 1024) ans += ac[i] * bc[i ^ k];
  cout << ans << endl;
}
0