显示原始代码
#include <cstdio>
#include <cstdlib>
using namespace std;
#define MAXNUM (1 << 30)
#define MAX (1 << 28) + 1
#define CMAX 30
struct QQ {
bool num;
int lc, rc;
QQ() {
num = false;
lc = rc = 0;
}
} a[6400000];
int tail = 0;
int ans = 0;
bool find(char *a, int n) {
int i = n / 8, j = n % 8;
bool k;
k = a[i] & (1 << j);
return k;
}
void change(char *a, int n) {
int i = n / 8, j = n % 8;
a[i] ^= (1 << j);
}
void work1()
{
int cen = 0, p = 0, x;
while (a[p].lc || a[p].rc) {
if (a[a[p].lc].num != a[a[p].rc].num) {
ans ^= (1 << cen);
}
{
x = a[p].lc;
a[p].lc = a[p].rc;
a[p].rc = x;
}
p = a[p].lc;
if (!p)
break;
cen++;
}
printf("%d\n", ans);
}
void work2()
{
int x, i, p, cen;
scanf("%d", &x);
p = 0;
cen = 0;
while (cen < 30) {
i = x & 1;
x >>= 1;
if (i) {
if (!a[p].rc) {
a[p].rc == ++tail;
}
p = a[p].rc;
a[p].num = !a[p].num;
ans ^= (1 << cen);
} else {
if (!a[p].lc) {
a[p].lc == ++tail;
}
p = a[p].lc;
a[p].num = !a[p].num;
}
cen++;
}
printf("%d\n", ans);
}
void read() {
int n, i, j;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &j);
if (j == 1)
work1();
else
work2();
}
}
int main() { read(); }