結果

問題 No.1142 XOR と XOR
ユーザー leaf_1415leaf_1415
提出日時 2020-07-31 21:59:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,431 bytes
コンパイル時間 1,546 ms
コンパイル使用メモリ 73,780 KB
実行使用メモリ 8,148 KB
最終ジャッジ日時 2023-08-07 21:59:10
合計ジャッジ時間 4,377 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,452 KB
testcase_01 AC 4 ms
5,396 KB
testcase_02 AC 4 ms
5,516 KB
testcase_03 AC 38 ms
8,048 KB
testcase_04 AC 29 ms
7,824 KB
testcase_05 AC 24 ms
7,420 KB
testcase_06 AC 29 ms
7,536 KB
testcase_07 AC 29 ms
8,088 KB
testcase_08 AC 35 ms
8,012 KB
testcase_09 AC 35 ms
8,148 KB
testcase_10 AC 35 ms
8,080 KB
testcase_11 AC 4 ms
5,496 KB
testcase_12 AC 4 ms
5,424 KB
testcase_13 AC 4 ms
5,452 KB
testcase_14 AC 20 ms
7,164 KB
testcase_15 AC 19 ms
6,936 KB
testcase_16 AC 5 ms
5,708 KB
testcase_17 AC 23 ms
7,384 KB
testcase_18 AC 9 ms
6,320 KB
testcase_19 AC 29 ms
7,416 KB
testcase_20 AC 21 ms
7,392 KB
testcase_21 AC 14 ms
7,008 KB
testcase_22 AC 10 ms
6,112 KB
testcase_23 AC 28 ms
7,252 KB
testcase_24 AC 30 ms
7,632 KB
testcase_25 AC 20 ms
7,152 KB
testcase_26 AC 29 ms
7,572 KB
testcase_27 AC 24 ms
7,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, m, k;
llint a[200005], b[200005];
llint A[1024], B[1024];

llint sum[200005], cnt[1024];
void calc(llint a[], llint A[], llint n)
{
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] ^ a[i];
	for(int i = 0; i < 1024; i++) cnt[i] = 0;
	for(int i = 0; i <= n; i++) cnt[sum[i]]++;
	for(int i = 0; i < 1024; i++){
		for(int j = 0; j < 1024; j++){
			A[i^j] += cnt[i]*cnt[j];
		}
	}
	A[0] -= n+1;
	for(int i = 0; i < 1024; i++) A[i] /= 2;
	for(int i = 0; i < 1024; i++) A[i] %= mod;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= m; i++) cin >> b[i];
	
	calc(a, A, n), calc(b, B, m);
	
	llint ans = 0;
	for(int i = 0; i < 1024; i++){
		ans += A[i] * B[i^k] % mod, ans %= mod;
	}
	cout << ans << endl;

	return 0;
}
0