七濑悠月
赛后过的,但感觉难度 2900* 高了,为啥我场上不会做。
二选一异或有点复杂,我们不妨记
我们经典地从高位往低位考虑,设
时间复杂度
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 1e5 + 10;
int n; LL A[N]; char S[N];
int main() {
freopen(".in", "r", stdin); freopen(".out", "w", stdout);
ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
int _; cin >> _;
while (_ --) {
cin >> n; LL Ans = 0, x;
for (int i = 1; i <= n; i ++) cin >> A[i], Ans ^= A[i];
for (int i = 1; i <= n; i ++) cin >> x, A[i] ^= x;
cin >> (S + 1);
for (int i = 59; i >= 0; i --) {
int t = n; while (t && !((A[t] >> i) & 1)) t --;
if (!t) continue;
if (((Ans >> i) & 1) ^ (S[t] == '1')) Ans ^= A[t];
for (int j = 1; j <= n; j ++) if ((A[j] >> i) & 1) A[j] ^= A[t];
} cout << Ans << "\n";
}
return 0;
}