显示原始代码
#include <bits/stdc++.h>
#define DB double
#define LL long long
#define MST(a, b) memset((a), (b), sizeof(a))
#define MRK() cout << "Mark" << endl;
#define WRT(x) cout << #x << " = " << (x) << endl;
#define MAXN 210000
#define MAXM 410000
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5
#define _ 0
using namespace std;
int son[MAXN << 30][2];
int cnt[MAXN << 30];
int ans;
int ncnt = 1;
void insert(int x) {
int pos = 1;
for (int i = 0; i < 30; i++) {
int to = (x & (1 << i) && 1);
if (to)
ans ^= (1 << i);
if (!son[pos][to])
son[pos][to] = ++ncnt;
pos = son[pos][to];
cnt[pos]++;
}
}
#define LS son[pos][0]
#define RS son[pos][1]
void add(int pos, int x) {
swap(LS, RS);
if (cnt[RS] ^ cnt[LS])
ans ^= x;
if (x < 29)
add(LS, x << 1);
}
int main() {
int n, op, x;
cin >> n;
while (n--) {
scanf("%d", &op);
if (op == 1)
add(1, 1);
else {
scanf("%d", &x);
insert(x);
}
printf("%d\n", ans);
}
return ~~(0 ^ _ ^ 0);
}