Pagini recente » Cod sursa (job #2062340) | Cod sursa (job #1892479) | Cod sursa (job #1952992) | Cod sursa (job #1333879) | Cod sursa (job #2038306)
#include <cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int M=666013;
int h(int key)
{
return key%M;
}
vector <int>TA[M+5];
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
int n,i,op,x,j,flag;
scanf("%d",&n);
vector<int>::iterator it;
for(i=1;i<=n;i++)
{
scanf("%d%d",&op,&x);
if(op==1)
TA[h(x)].push_back(x);
if(op==2)
{
it=find(TA[h(x)].begin(),TA[h(x)].end(),x);
if(it!=TA[h(x)].end())
TA[h(x)].erase(it);
}
if(op==3)
{
it=find(TA[h(x)].begin(),TA[h(x)].end(),x);
if(it!=TA[h(x)].end())
printf("%d\n",1);
else
printf("%d\n",0);
}
}
return 0;
}