結果

問題 No.1142 XOR と XOR
ユーザー chocono2230chocono2230
提出日時 2020-08-01 12:16:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 2,365 bytes
コンパイル時間 1,688 ms
コンパイル使用メモリ 169,148 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:34:48
合計ジャッジ時間 4,100 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,816 KB
testcase_01 AC 7 ms
6,940 KB
testcase_02 AC 8 ms
6,940 KB
testcase_03 AC 108 ms
6,940 KB
testcase_04 AC 74 ms
6,944 KB
testcase_05 AC 61 ms
6,944 KB
testcase_06 AC 74 ms
6,944 KB
testcase_07 AC 64 ms
6,944 KB
testcase_08 AC 94 ms
6,940 KB
testcase_09 AC 88 ms
6,940 KB
testcase_10 AC 90 ms
6,940 KB
testcase_11 AC 7 ms
6,940 KB
testcase_12 AC 8 ms
6,940 KB
testcase_13 AC 8 ms
6,944 KB
testcase_14 AC 50 ms
6,940 KB
testcase_15 AC 50 ms
6,944 KB
testcase_16 AC 11 ms
6,944 KB
testcase_17 AC 52 ms
6,944 KB
testcase_18 AC 17 ms
6,940 KB
testcase_19 AC 75 ms
6,944 KB
testcase_20 AC 52 ms
6,944 KB
testcase_21 AC 32 ms
6,944 KB
testcase_22 AC 22 ms
6,940 KB
testcase_23 AC 68 ms
6,940 KB
testcase_24 AC 77 ms
6,940 KB
testcase_25 AC 49 ms
6,940 KB
testcase_26 AC 71 ms
6,944 KB
testcase_27 AC 61 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

void fc(int n, vector<int> &a, vector<mint> &xxa){
  vector<int> xsa(n+1, 0);
  vector<mint> xa(1024, 0);
  rep(i, n) xsa.at(i+1) = xsa.at(i) ^ a.at(i);
  rep(i, n+1) xa.at(xsa.at(i)) += 1;
  rep(i, 1024)rep(j, 1024){
    xxa.at(i^j) += xa.at(i) * xa.at(j);
  }
  xxa.at(0) -= n+1;
  rep(i, 1024) xxa.at(i) /= 2;
  // cerr << xa.at(0).x << endl;
}

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<int> b(m);
  rep(i, m) cin >> b.at(i);
  vector<mint> xa(1024, 0), xb(1024, 0);
  fc(n, a, xa);
  fc(m, b, xb);
  mint ans = 0;
  rep(i, 1024){
    int j = k ^ i;
    ans += xa.at(i) * xb.at(j);
  }
  cout << ans.x << endl;
  return 0;
}
0