比赛 |
集训 |
评测结果 |
AAAEEEEEEE |
题目名称 |
镜牢 |
最终得分 |
30 |
用户昵称 |
LikableP |
运行时间 |
1.170 s |
代码语言 |
C++ |
内存使用 |
2.00 MiB |
提交时间 |
2025-07-03 11:40:01 |
显示代码纯文本
#include <cstdio>
typedef __int128 int128;
template <typename T> T read();
template <typename T> void write(T, char);
template <typename T> T max(T, T);
template <typename T> T min(T, T);
void dfs(int, int128);
const int MAXN = 5e4 + 10;
int n;
int128 a[MAXN], b[MAXN], c[MAXN];
int128 ans;
int main() {
freopen("mirror.in", "r", stdin);
freopen("mirror.out", "w", stdout);
n = read<int>();
for (int i = 1; i <= n; ++i) a[i] = read<int128>();
for (int i = 1; i <= n; ++i) b[i] = read<int128>();
for (int i = 1; i <= n; ++i) c[i] = read<int128>();
dfs(1, 0);
write(ans, '\n');
return 0;
}
void dfs(int now, int128 x) {
if (now == n + 1) {
ans = max(ans, x);
return;
}
if (c[now]) dfs(now + 1, x ^ a[now]), dfs(now + 1, x ^ b[now]);
if (!c[now]) dfs(now + 1, min(x ^ a[now], x ^ b[now]));
}
template <typename T> T min(T x, T y) {
return x < y ? x : y;
}
template <typename T> T max(T x, T y) {
return x > y ? x : y;
}
#define isdigit(ch) (ch >= '0' && ch <= '9')
template <typename T> T read() {
T res = 0, f = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') f = -1;
for (; isdigit(ch); ch = getchar()) res = (res << 3) + (res << 1) + (ch ^ 48);
return res * f;
}
template <typename T> void write(T x, char ed) {
if (x < 0) x = -x, putchar('-');
static int sta[sizeof(T) << 2], top = 0;
do {
sta[++top] = x % 10;
x /= 10;
} while (x);
while (top) {
putchar(sta[top--] ^ 48);
}
putchar(ed);
}