結果

問題 No.1142 XOR と XOR
ユーザー ttkkggwwttkkggww
提出日時 2020-08-01 09:38:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,146 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 168,032 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:34:35
合計ジャッジ時間 3,889 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,812 KB
testcase_01 AC 5 ms
6,944 KB
testcase_02 AC 5 ms
6,940 KB
testcase_03 AC 100 ms
6,944 KB
testcase_04 AC 66 ms
6,940 KB
testcase_05 AC 57 ms
6,940 KB
testcase_06 AC 78 ms
6,944 KB
testcase_07 AC 65 ms
6,944 KB
testcase_08 AC 87 ms
6,944 KB
testcase_09 AC 86 ms
6,940 KB
testcase_10 AC 89 ms
6,940 KB
testcase_11 AC 6 ms
6,944 KB
testcase_12 AC 6 ms
6,944 KB
testcase_13 AC 6 ms
6,944 KB
testcase_14 AC 47 ms
6,944 KB
testcase_15 AC 46 ms
6,940 KB
testcase_16 AC 9 ms
6,944 KB
testcase_17 AC 47 ms
6,944 KB
testcase_18 AC 15 ms
6,940 KB
testcase_19 AC 70 ms
6,940 KB
testcase_20 AC 48 ms
6,940 KB
testcase_21 AC 30 ms
6,940 KB
testcase_22 AC 21 ms
6,940 KB
testcase_23 AC 68 ms
6,940 KB
testcase_24 AC 75 ms
6,940 KB
testcase_25 AC 47 ms
6,940 KB
testcase_26 AC 71 ms
6,944 KB
testcase_27 AC 57 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main()
{
	ll n, m, k;
	cin >> n >> m >> k;
	vector<int> a(n), b(m);
	for (auto &i : a)
		cin >> i;
	for (auto &i : b)
		cin >> i;
	vector<int> suma(n + 1), sumb(m + 1);
	for (int i = 0; i < n; i++)
		suma[i + 1] ^= suma[i] ^ a[i];
	for (int i = 0; i < m; i++)
		sumb[i + 1] ^= sumb[i] ^ b[i];
	vector<ll> cnta(1024), cntb(1024);
	for (int i = 0; i < n + 1; i++)
		cnta[suma[i]]++;
	for (int i = 0; i < m + 1; i++)
		cntb[sumb[i]]++;
	vector<ll> ncnta(1024), ncntb(1024);
	for (int i = 0; i < 1024; i++)
		for (int j = i; j < 1024; j++)
		{
			if (i == j)
			{
				ncnta[i ^ j] += (cnta[i]-1) * cnta[j]/2 % MOD;
				ncnta[i ^ j] %= MOD;
				ncntb[i ^ j] += (cntb[i]-1) * cntb[j]/2 % MOD;
				ncntb[i ^ j] %= MOD;
				continue;
			}
			ncnta[i ^ j] += cnta[i] * cnta[j] % MOD;
			ncnta[i ^ j] %= MOD;
			ncntb[i ^ j] += cntb[i] * cntb[j] % MOD;
			ncntb[i ^ j] %= MOD;
		}
	ll ans = 0;
	for(int i = 0;i<1024;i++)
	{
		for(int j = 0;j<1024;j++)
		{
			if((i^j)==k)
			{
				ans += ncnta[i]*ncntb[j];
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;
}
0