Pagini recente » Cod sursa (job #1872714) | Cod sursa (job #1363340) | Cod sursa (job #2103464) | Cod sursa (job #978025) | Cod sursa (job #2103456)
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define VI vector<int>
#define PII pair<int,int>
#define PDD pair<double,double>
#define ll long long
#define lf double
#define pb push_back
#define For(i, j, n)for(int i = j;i <= n;i++)
#define iFor(i, j, n)for(int i = n;i >= j;i--)
#define R scanf
#define S scanf
#define P printf
#define fin stdin
#define fout stdout
#define DBG 1
#define BUF 1 << 17
char buf[BUF];
int pos = BUF;
inline char next() {
if(pos == BUF)
fread(buf, 1, BUF, fin), pos = 0;
return buf[pos++];
}
inline int read() {
int x = 0;
char ch = next();
while(!isdigit(ch))
ch = next();
while(isdigit(ch)) {
x = x * 10 + ch - '0', ch = next();
}
return x;
}
int n;
const int maxn = 1e6 + 3;
struct myhash {
static const int MOD = 666013;
int k, next[maxn], lista[MOD], val[maxn];
inline void insert(int nr) {
int mod = nr % MOD;
val[++k] = mod;
next[k] = lista[mod];
lista[mod] = k;
}
inline void erase(int nr) {
int mod = nr % MOD;
int poz = lista[mod];
if(val[poz] == nr) {
lista[mod] = next[poz];
return;
}
int prev;
while(poz) {
int el = val[poz];
if(el == nr) {
break;
}
prev = poz;
poz = next[poz];
}
if(poz) {
next[prev] = next[poz];
}
}
inline bool check(int nr) {
int mod = nr % MOD;
int poz = lista[mod];
while(poz) {
int el = val[poz];
if(el == nr) {
return 1;
}
poz = next[poz];
}
return 0;
}
} hh;
int main() {
if(DBG) {
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
}
n = read();
while(n) {
n--;
int op, x;
op = read(), x = read();
if(op == 1) {
if(hh.check(x) == 0)
hh.insert(x);
}
else if(op == 2) {
hh.erase(x);
}
else if(op == 3) {
P("%d\n", hh.check(x));
}
}
return 0;
}