結果

問題 No.1142 XOR と XOR
ユーザー nikkukunnikkukun
提出日時 2020-07-31 22:14:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,414 bytes
コンパイル時間 1,454 ms
コンパイル使用メモリ 163,972 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:20:25
合計ジャッジ時間 3,126 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,816 KB
testcase_01 AC 6 ms
6,940 KB
testcase_02 AC 6 ms
6,940 KB
testcase_03 AC 41 ms
6,944 KB
testcase_04 AC 33 ms
6,944 KB
testcase_05 AC 28 ms
6,940 KB
testcase_06 AC 32 ms
6,944 KB
testcase_07 AC 32 ms
6,940 KB
testcase_08 AC 40 ms
6,944 KB
testcase_09 AC 40 ms
6,944 KB
testcase_10 AC 39 ms
6,940 KB
testcase_11 AC 6 ms
6,940 KB
testcase_12 AC 6 ms
6,940 KB
testcase_13 AC 5 ms
6,940 KB
testcase_14 AC 23 ms
6,944 KB
testcase_15 AC 23 ms
6,940 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 26 ms
6,944 KB
testcase_18 AC 10 ms
6,940 KB
testcase_19 AC 32 ms
6,940 KB
testcase_20 AC 23 ms
6,944 KB
testcase_21 AC 17 ms
6,944 KB
testcase_22 AC 12 ms
6,940 KB
testcase_23 AC 32 ms
6,940 KB
testcase_24 AC 35 ms
6,944 KB
testcase_25 AC 23 ms
6,940 KB
testcase_26 AC 33 ms
6,940 KB
testcase_27 AC 27 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

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