Pagini recente » Cod sursa (job #1735491) | Cod sursa (job #520989) | Cod sursa (job #2628446) | Cod sursa (job #911851) | Cod sursa (job #641950)
Cod sursa(job #641950)
#include <stdio.h>
#include <vector>
using namespace std;
#define MOD 100003
int n;
vector<int> hash[MOD];
inline vector<int>::iterator gaseste(int x){
int ind=x%MOD;
vector<int>::iterator it;
for (it=hash[ind].begin(); it!=hash[ind].end(); it++)
if (*it==x) return it;
return hash[ind].end();
}
void insert(int x){
int ind=x%MOD;
if (gaseste(x)==hash[ind].end())
hash[ind].push_back(x);
}
void sterge(int x){
int ind=x%MOD;
vector<int>::iterator it=gaseste(x);
if (it!=hash[ind].end())
hash[ind].erase(it);
}
int main(){
int op,nr;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%d %d",&op,&nr);
if (op==1) insert(nr);
if (op==2) sterge(nr);
if (op==3) printf("%d\n",gaseste(nr)==hash[nr].end()?0:1);
}
return 0;
}