結果

問題 No.1142 XOR と XOR
ユーザー 夜
提出日時 2021-03-03 22:45:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,338 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 94,896 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 16:46:12
合計ジャッジ時間 3,336 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,812 KB
testcase_01 AC 13 ms
6,944 KB
testcase_02 AC 13 ms
6,944 KB
testcase_03 AC 110 ms
6,940 KB
testcase_04 AC 76 ms
6,940 KB
testcase_05 AC 64 ms
6,944 KB
testcase_06 AC 78 ms
6,940 KB
testcase_07 AC 69 ms
6,944 KB
testcase_08 AC 95 ms
6,940 KB
testcase_09 AC 93 ms
6,940 KB
testcase_10 AC 94 ms
6,940 KB
testcase_11 AC 13 ms
6,940 KB
testcase_12 AC 13 ms
6,944 KB
testcase_13 AC 13 ms
6,940 KB
testcase_14 AC 54 ms
6,944 KB
testcase_15 AC 55 ms
6,940 KB
testcase_16 AC 17 ms
6,944 KB
testcase_17 AC 56 ms
6,940 KB
testcase_18 AC 23 ms
6,940 KB
testcase_19 AC 78 ms
6,940 KB
testcase_20 AC 55 ms
6,940 KB
testcase_21 AC 39 ms
6,944 KB
testcase_22 AC 28 ms
6,944 KB
testcase_23 AC 74 ms
6,940 KB
testcase_24 AC 82 ms
6,940 KB
testcase_25 AC 53 ms
6,940 KB
testcase_26 AC 80 ms
6,940 KB
testcase_27 AC 66 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long co[1030] = {}, co1[1030] = {};
long long ca[1030] = {}, cb[1030] = {};
long long mod = 1000000007, z = 0;
int main() {
	int n, m, k;
	cin >> n >> m >> k;
	int a = 0, b = 0;
	co[0] = 1, co1[0] = 1;
	for (int i = 0; i < n; i++) {
		int a1;
		cin >> a1;
		a ^= a1;
		co[a]++;
	}
	for (int i = 0; i < m; i++) {
		int b1;
		cin >> b1;
		b ^= b1;
		co1[b]++;
	}
	for (int i = 0; i < 1024; i++) {
		for (int j = i; j < 1024; j++) {
			if (i == j) {
				ca[i ^ j] += co[i] * max(z,co[j] - 1) / 2;
				cb[i ^ j] += co1[i] * max(z, co1[j] - 1) / 2;
				ca[i ^ j] %= mod;
				cb[i ^ j] %= mod;
			}
			else {
				ca[i ^ j] += co[i] * co[j];
				cb[i ^ j] += co1[i] * co1[j];
				ca[i ^ j] %= mod;
				cb[i ^ j] %= mod;
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < 1024; i++) {
		for (int j = i; j < 1024; j++) {
			if ((i ^ j) == k) {
				if (i == j) {
					ans += ca[i] * cb[j];
					ans %= mod;
				}
				else {
					ans += ca[i] * cb[j];
					ans %= mod;
					ans += cb[i] * ca[j];
					ans %= mod;
				}
			}
		}
	}
	cout << ans << endl;
}
0