Cod sursa(job #905188)
#include <stdio.h>
#include <list>
#include <vector>
#include <math.h>
using namespace std;
vector < list<int> > hash;
list <int>::iterator it;
float A;
int m, n, op, nr;
inline int hashing(float x){
return (int)(m * ( (float)x * A - (int)(x * A) ));
}
inline void add(int x){
hash[ hashing(x) ].push_back(x);
}
inline void del(int x){
for(it = hash[ hashing(x) ].begin(); it != hash[ hashing(x) ].end(); ++it)
if(*it == x){
hash[ hashing(x) ].erase(it);
return;
}
}
inline int search(int x){
for(it = hash[ hashing(x) ].begin(); it != hash[ hashing(x) ].end(); ++it)
if(*it == x) return 1;
return 0;
}
void solve(){
A = (sqrt(5) - 1)/2;
m = 524288;
scanf("%i", &n);
hash.resize(m+2);
for(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;
}