結果
| 問題 |
No.1142 XOR と XOR
|
| ユーザー |
ゆきのん
|
| 提出日時 | 2020-08-30 22:06:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 105 ms / 2,000 ms |
| コード長 | 1,609 bytes |
| コンパイル時間 | 2,117 ms |
| コンパイル使用メモリ | 170,644 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 03:49:13 |
| 合計ジャッジ時間 | 4,080 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};
int main(){
int n,m,k;cin >> n >> m >> k;
vector<int> a(n),b(m);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < m; i++) {
cin >> b[i];
}
vector<LL> ac(1<<11, 0), bc(1<<11, 0);
int A = 0, B = 0;
ac[0]++;
for (int i = 0; i < n; i++) {
A ^= a[i];
ac[A]++;
}
bc[0]++;
for (int i = 0; i < m; i++) {
B ^= b[i];
bc[B]++;
}
vector<LL> aa(1<<11, 0), bb(1<<11, 0);
for (int i = 0; i < 1<<10; i++) {
aa[i ^ i] = (aa[i ^ i] + ac[i] * (ac[i] - 1) / 2)%mod;
bb[i ^ i] = (bb[i ^ i] + bc[i] * (bc[i] - 1) / 2)%mod;
for (int j = i + 1; j < 1<<10; j++) {
aa[i ^ j] = (aa[i ^ j] + ac[i] * ac[j]) %mod;
bb[i ^ j] = (bb[i ^ j] + bc[i] * bc[j]) %mod;
}
}
LL ans = 0;
for (int i = 0; i < 1<<10; i++) {
ans = (ans + aa[i] * bb[i ^ k])%mod;
}
cout << ans << endl;
return 0;
}
ゆきのん