记录编号 602324 评测结果 AAAAAAAAAA
题目名称 4167.镜牢 最终得分 100
用户昵称 GravatarOTTF 是否通过 通过
代码语言 C++ 运行时间 1.491 s
提交时间 2025-07-03 15:57:14 内存使用 4.33 MiB
显示代码纯文本

#include <cstdio>
#include <iostream>
#include <map>

using namespace std;

constexpr int N = 114514;

int n;
long long a[N];
bool c[N];
long long res;

int main () {

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	long long b;
	for (int i = 1; i <= n; i++) {
		cin >> b;
		res ^= b;
		a[i] ^= b;

	}
	for (int i = 1; i <= n; i++) {
		cin >> c[i];
	}

	for (int i = 59; i >= 0; i--) {
		long long x = 0;
		long long y = 0;
		for (int j = n; j >= 1; j--) {
			if (a[j] & (1ll << i)) {
				a[j] ^= (x ? x : (y = c[j], x = a[j]));
			}
			res ^= (((res >> i & 1)) ^ y) * x;
		}
	}

	cout << res << endl;
	
	return 0;
}