Pagini recente » Cod sursa (job #775470) | Cod sursa (job #1302706) | Cod sursa (job #1084392) | Cod sursa (job #417115) | Cod sursa (job #2306047)
#include<cstdio>
#define M 1000001
typedef struct O
{
int I;
struct O *U;
}N;
int n,y,x;
N *h[M],*p,*q;
int F(N *l,int y)
{
for(p=l;p;p=p->U)
if(p->I==y)
return 1;
return 0;
}
int main()
{
freopen("hashuri.in","r",stdin),freopen("hashuri.out","w",stdout),scanf("%d",&n);
while(n--)
{
scanf("%d%d",&x,&y);
if(x==1)
{
if(!F(h[y%M],y))
{
p=new N;
p->U=h[y%M],p->I=y,h[y%M]=p;
}
}
else if(x==2)
{
if(F(h[y%M],y))
{
for(p=q=h[y%M];p&&p->I!=y;q=p,p=p->U);
if(p)
{
if(q==p)
h[y%M]=h[y%M]->U;
else
q->U=p->U;
delete p;
}
}
}
else
printf("%d\n",F(h[y%M],y));
}
}