結果

問題 No.1142 XOR と XOR
ユーザー nikkukunnikkukun
提出日時 2020-07-31 22:14:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,414 bytes
コンパイル時間 1,424 ms
コンパイル使用メモリ 165,800 KB
実行使用メモリ 5,116 KB
最終ジャッジ日時 2023-08-07 22:02:43
合計ジャッジ時間 3,350 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 5 ms
4,376 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 40 ms
5,116 KB
testcase_04 AC 31 ms
4,656 KB
testcase_05 AC 26 ms
4,380 KB
testcase_06 AC 31 ms
4,784 KB
testcase_07 AC 32 ms
4,956 KB
testcase_08 AC 38 ms
4,928 KB
testcase_09 AC 37 ms
4,960 KB
testcase_10 AC 37 ms
4,924 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 22 ms
4,380 KB
testcase_15 AC 22 ms
4,392 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 25 ms
4,544 KB
testcase_18 AC 10 ms
4,376 KB
testcase_19 AC 32 ms
4,836 KB
testcase_20 AC 22 ms
4,412 KB
testcase_21 AC 16 ms
4,376 KB
testcase_22 AC 11 ms
4,380 KB
testcase_23 AC 30 ms
4,556 KB
testcase_24 AC 33 ms
4,724 KB
testcase_25 AC 21 ms
4,376 KB
testcase_26 AC 32 ms
4,600 KB
testcase_27 AC 26 ms
4,384 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