Pagini recente » Cod sursa (job #299227) | Cod sursa (job #537978) | Cod sursa (job #630405) | Cod sursa (job #3124758) | Cod sursa (job #2306061)
#include<cstdio>
#define M 666013
struct N
{
int I;
N *U;
};
int n,y,x,o;
N *h[M],*p,*q;
int main()
{
freopen("hashuri.in","r",stdin),freopen("hashuri.out","w",stdout),scanf("%d",&n);
while(n--)
{
scanf("%d%d",&x,&y);
for(o=0,p=h[y%M];p&&!o;p=p->U)
if(p->I==y)
o=1;
if(x==1&&!o)
{
p=new N;
p->U=h[y%M],p->I=y,h[y%M]=p;
continue;
}
if(x==2&&o)
{
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;
}
continue;
}
printf("%d\n",o);
}
}