結果
| 問題 |
No.1142 XOR と XOR
|
| ユーザー |
tonegawa
|
| 提出日時 | 2020-08-11 01:25:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 2,000 ms |
| コード長 | 1,643 bytes |
| コンパイル時間 | 1,135 ms |
| コンパイル使用メモリ | 98,784 KB |
| 実行使用メモリ | 6,656 KB |
| 最終ジャッジ日時 | 2024-11-08 03:48:37 |
| 合計ジャッジ時間 | 3,533 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#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';
}
tonegawa