結果

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

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 1000000007


std::vector<int> process(int *a, int n) {
	int cnt0[1024];
	std::vector<int> cnt1(1024);
	memset(cnt0, 0, sizeof(cnt0));
	int t = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < 1024; j++) {
			cnt1[j ^ t] += cnt0[j];
			if (cnt1[j ^ t] >= MOD) cnt1[j ^ t] -= MOD;
		}
		cnt0[t]++;
		if (i < n) t ^= a[i];
	}
	return cnt1;
}

int main() {
	int n = ri();
	int m = ri();
	int k = ri();
	int a[n], b[m];
	for (auto &i : a) i = ri();
	for (auto &i : b) i = ri();
	auto r0 = process(a, n);
	auto r1 = process(b, m);
	int res = 0;
	for (int i = 0; i < 1024; i++) res = (res + (int64_t) r0[i] * r1[i ^ k]) % MOD;
	printf("%d\n", res);
	return 0;
}
0