显示原始代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n;
struct node {
int s[2];
int cn;
int d;
int ed;
} t[N * 100];
int cn = 1;
int te[30], an;
void ins(int x) {
int no = 1;
t[no].cn++;
do {
if (x & 1) {
te[t[no].d]++;
if (!t[no].s[1]) {
t[no].s[1] = ++cn;
t[cn].d = t[no].d + 1;
}
no = t[no].s[1];
t[no].cn++;
} else {
if (!t[no].s[0]) {
t[no].s[0] = ++cn;
t[cn].d = t[no].d + 1;
}
no = t[no].s[0];
t[no].cn++;
}
x >>= 1;
} while (x);
t[no].ed++;
}
void add() {
int no = 1;
while (t[no].cn) {
te[t[no].d] -= t[t[no].s[1]].cn;
te[t[no].d] += t[t[no].s[0]].cn;
swap(t[no].s[0], t[no].s[1]);
no = t[no].s[0];
if (!t[no].s[1]) {
t[no].s[1] = ++cn;
t[cn].d = t[no].d + 1;
}
t[t[no].s[1]].cn += t[no].ed;
}
}
int main() {
cin >> n;
while (n--) {
int op;
cin >> op;
if (op == 1) {
add();
an = 0;
for (int i = 0; i < 30; ++i) {
if (te[i] & 1) {
an += (1 << i);
}
}
cout << an << '\n';
} else {
int x;
cin >> x;
ins(x);
an = 0;
for (int i = 0; i < 30; ++i) {
if (te[i] & 1) {
an += (1 << i);
}
}
cout << an << '\n';
}
}
return 0;
}