結果

問題 No.1142 XOR と XOR
ユーザー nikkukun
提出日時 2020-07-31 22:14:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,414 bytes
コンパイル時間 1,615 ms
コンパイル使用メモリ 166,920 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 03:27:59
合計ジャッジ時間 3,466 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

// 21:03 - 21:10
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 2e5 + 5;
const int M = 1024;
const int MOD = 1e9 + 7;
const int INV2 = 500000004;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int a[N], b[N];
int cnta[M], cntb[M];

void Cov(int x[]) {
	int tmp[M];
	memset(tmp, 0, sizeof(tmp));

	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++) {
			int k = i ^ j;
			tmp[k] = (tmp[k] + 1LL * x[i] * x[j]) % MOD;
		}

	for (int i = 0; i < M; i++)
		x[i] = tmp[i];
}

int main() {
	ios::sync_with_stdio(0);

	int n, m, k;
	cin >> n >> m >> k;
	cnta[0] = cntb[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] ^= a[i - 1];
		cnta[a[i]]++;
	}
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		b[i] ^= b[i - 1];
		cntb[b[i]]++;
	}
	Cov(cnta);
	Cov(cntb);

	cnta[0] = (cnta[0] - n - 1 + MOD) % MOD;
	cntb[0] = (cntb[0] - m - 1 + MOD) % MOD;
	for (int i = 0; i < M; i++) {
		cnta[i] = 1LL * cnta[i] * INV2 % MOD;
		cntb[i] = 1LL * cntb[i] * INV2 % MOD;
	}

	ll ans = 0;
	for (int i = 0; i < M; i++)
		ans = (ans + 1LL * cnta[i] * cntb[i ^ k]) % MOD;
	ans = (ans % MOD + MOD) % MOD;
	cout << ans << endl;

	return 0;
}
0