Cod sursa(job #905251)
#include <stdio.h>
#include <list>
#include <vector>
#include <math.h>
using namespace std;
vector < list<int> > hash;
list <int>::iterator it;
int m, n, op, nr, ind;
inline int hashing(int x){
return (x % m);
}
inline void add(int x){
hash[ hashing(x) ].push_back(x);
}
inline void del(int x){
ind = hashing(x);
for(it = hash[ ind ].begin(); it != hash[ ind ].end(); ++it)
if(*it == x){
hash[ ind ].erase(it);
return;
}
}
inline int search(int x){
ind = hashing(x);
for(it = hash[ ind ].begin(); it != hash[ ind ].end(); ++it)
if(*it == x) return 1;
return 0;
}
void solve(){
m = 666013;
scanf("%i", &n);
hash.resize(m+2);
for(register int i = 1; i <= n; ++i){
scanf("%i %i", &op, &nr);
if(op == 1) add(nr);
else if (op == 2) del(nr);
else printf("%i\n", search(nr));
}
}
int main(){
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
solve();
fclose(stdin);
fclose(stdout);
return 0;
}