Pagini recente » Cod sursa (job #1929175) | Cod sursa (job #2610771) | Cod sursa (job #2590656) | Cod sursa (job #453713) | Cod sursa (job #1583833)
#include <stdio.h>
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
int n;
vector<int> _hash[MOD];
vector<int>::iterator find(int x)
{
int key = x%MOD;
vector<int>::iterator it;
for(it = _hash[key].begin();it<_hash[key].end();it++)
if(*it==x)
return it;
return _hash[key].end();
}
void add(int x)
{
int key = x%MOD;
if(find(x)==_hash[key].end())
_hash[key].push_back(x);
}
void erase(int x)
{
int key = x%MOD;
vector<int>::iterator it;
it = find(x);
if(it!=_hash[key].end())
_hash[key].erase(it);
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
int op,x;
for(int i=1;i<=n;i++)
{
scanf("%d",&op);
scanf("%d",&x);
if(op==1)
{
add(x);
continue;
}
if(op==2)
{
erase(x);
continue;
}
if(op==3)
printf("%d\n",find(x)!=_hash[x%MOD].end());
}
return 0;
}