Pagini recente » Cod sursa (job #270424) | Cod sursa (job #721939) | Cod sursa (job #2956986) | Cod sursa (job #820958) | Cod sursa (job #2306090)
#include<cstdio>
#define M 666013
struct O
{
int I;
O *U;
}N;
int n,y,x,z;
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),z=y%M;
for(p=q=h[z];p&&p->I!=y;q=p,p=p->U);
if(x==1&&!p)
{
p=new N;
p->U=h[z],p->I=y,h[z]=p;
continue;
}
if(x==2&&p)
{
q==p?h[z]=h[z]->U:q->U=p->U;
continue;
}
if(x==3)
printf("%d\n",p?1:0);
}
}