#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, LOG_A = 30;
int k;
int basis[LOG_A];
int num[N];
int sz;
int ct = 1;
void insertVector(int mask) {
for (int i = 0; i < LOG_A; i++) {
if ((mask & 1 << i) == 0) continue;
if (!basis[i]) {
basis[i] = mask;
++sz;
return;
}
mask ^= basis[i];
}
}
int maxxor(int cur){
for (int i = LOG_A; i >= 0; i--){
if ((cur & 1<<i) == 0){
if (basis[i]){
cur ^= basis[i];
}
}
}
return cur;
}
int main() {
int q;
cin >> q;
while (q--) {
string Q;
int a,b;
cin >> Q >> a >> b;
if (Q == "Add"){
num[++ct] = num[a]^b;
insertVector(num[ct]);
}
else if (Q == "Query"){
printf("%d\n",maxxor(num[a]));
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
621 ms |
2168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |