結果

問題 No.1142 XOR と XOR
ユーザー Example0911Example0911
提出日時 2020-08-25 19:23:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 1,148 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 167,076 KB
実行使用メモリ 9,700 KB
最終ジャッジ日時 2024-04-25 16:42:29
合計ジャッジ時間 3,681 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
6,812 KB
testcase_01 AC 14 ms
6,944 KB
testcase_02 AC 14 ms
6,940 KB
testcase_03 AC 50 ms
9,472 KB
testcase_04 AC 41 ms
8,192 KB
testcase_05 AC 37 ms
7,296 KB
testcase_06 AC 41 ms
8,676 KB
testcase_07 AC 40 ms
9,572 KB
testcase_08 AC 48 ms
9,472 KB
testcase_09 AC 49 ms
9,572 KB
testcase_10 AC 48 ms
9,700 KB
testcase_11 AC 14 ms
6,940 KB
testcase_12 AC 14 ms
6,940 KB
testcase_13 AC 14 ms
6,940 KB
testcase_14 AC 32 ms
6,944 KB
testcase_15 AC 32 ms
7,268 KB
testcase_16 AC 15 ms
6,940 KB
testcase_17 AC 33 ms
7,936 KB
testcase_18 AC 18 ms
6,944 KB
testcase_19 AC 41 ms
8,320 KB
testcase_20 AC 32 ms
6,944 KB
testcase_21 AC 25 ms
6,940 KB
testcase_22 AC 20 ms
6,944 KB
testcase_23 AC 41 ms
7,936 KB
testcase_24 AC 43 ms
8,576 KB
testcase_25 AC 31 ms
6,940 KB
testcase_26 AC 41 ms
8,288 KB
testcase_27 AC 35 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int mod = 1000000007;
ll N, M, K;
ll a[200010], b[200010];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> M >> K;
	rep(i, N)cin >> a[i];
	rep(i, M)cin >> b[i];
	vector<ll>ruia(N + 1), ruib(M + 1);
	rep(i, N) {
		ruia[i + 1] = ruia[i] ^ a[i];
	}
	rep(i, M) {
		ruib[i + 1] = ruib[i] ^ b[i];
	}
	vector<ll>cnta(1 << 10), cntb(1 << 10);
	rep(i, N + 1)cnta[ruia[i]]++;
	rep(i, M + 1)cntb[ruib[i]]++;
	vector<ll>c(1 << 10), d(1 << 10);
	rep(i, 1 << 10) {
		for (int j = i + 1; j < (1 << 10); j++) {
			c[i ^ j] += cnta[i] * cnta[j]; c[i^j] %= mod;
			d[i^j] += cntb[i] * cntb[j]; d[i^j] %= mod;
		}
	}
	rep(i, 1 << 10) {
		c[0] += (cnta[i] * (cnta[i] - 1)) / 2; c[0] %= mod;
		d[0] += (cntb[i] * (cntb[i] - 1)) / 2; d[0] %= mod;
	}
	ll ans = 0;
	rep(i, 1 << 10) {
		rep(j, 1 << 10) {
			if ((i^j) == K) {
				ans += c[i] * d[j]; ans %= mod;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0