結果

問題 No.1142 XOR と XOR
ユーザー tonegawatonegawa
提出日時 2020-08-11 01:25:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 1,643 bytes
コンパイル時間 870 ms
コンパイル使用メモリ 98,964 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:42:14
合計ジャッジ時間 3,789 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 99 ms
6,940 KB
testcase_04 AC 68 ms
6,944 KB
testcase_05 AC 56 ms
6,940 KB
testcase_06 AC 71 ms
6,944 KB
testcase_07 AC 59 ms
6,944 KB
testcase_08 AC 86 ms
6,944 KB
testcase_09 AC 88 ms
6,940 KB
testcase_10 AC 88 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 47 ms
6,944 KB
testcase_15 AC 47 ms
6,940 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 45 ms
6,940 KB
testcase_18 AC 12 ms
6,944 KB
testcase_19 AC 71 ms
6,940 KB
testcase_20 AC 47 ms
6,944 KB
testcase_21 AC 31 ms
6,944 KB
testcase_22 AC 19 ms
6,944 KB
testcase_23 AC 67 ms
6,940 KB
testcase_24 AC 74 ms
6,940 KB
testcase_25 AC 41 ms
6,940 KB
testcase_26 AC 66 ms
6,944 KB
testcase_27 AC 55 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m, k;std::cin >> n >> m >> k;
  //鳩の巣よりそれぞれ2^10種類
  vector<ll> a(n), b(m);
  vector<ll> x(1024, 0), y(1024, 0);
  vector<ll> cnt1(1024, 0), cnt2(1024, 0);

  x[0] = y[0] = 1;
  ll now = 0;
  for(int i=0;i<n;i++){
    ll t;std::cin >> t;
    now^=t;
    x[now]++;
  }
  now = 0;
  for(int i=0;i<m;i++){
    ll t;std::cin >> t;
    now^=t;
    y[now]++;
  }
  ll P = 1000000007;
  for(int i=0;i<1024;i++){
    ll now = x[i];
    if(now==0) continue;
    for(int j=0;j<1024;j++){
      ll to_num = x[j];
      if(i==j) to_num--;
      cnt1[i^j] += now * to_num;
    }
  }
  for(int i=0;i<1024;i++){
    ll now = y[i];
    if(now==0) continue;
    for(int j=0;j<1024;j++){
      ll to_num = y[j];
      if(i==j) to_num--;
      cnt2[i^j] += now * to_num;
    }
  }
  for(int i=0;i<1024;i++) cnt1[i]/=2, cnt2[i]/=2;
  for(int i=0;i<1024;i++) cnt1[i]%=P, cnt2[i]%=P; 
  ll ans = 0;
  for(int i=0;i<1024;i++){
    ll need = k^i;
    ans = (ans + (cnt1[i] * cnt2[need])%P)%P;
  }
  std::cout << ans << '\n';
}
0