Pagini recente » Cod sursa (job #2504663) | Cod sursa (job #1658370) | Cod sursa (job #546386) | Cod sursa (job #1971082) | Cod sursa (job #408413)
Cod sursa(job #408413)
#include <stdio.h>
long i,j,poz,x,y,n,q,a[3][1000010],z,st[700000],fin[700000],l,ok;
int main()
{freopen("hashuri.in","r",stdin);freopen("hashuri.out","w",stdout);
q=657013;l=0;
scanf("%ld",&n);
for(i=1;i<=n;i++)
{scanf("%ld%ld",&y,&x);
if(y==1){poz=x%q;
if(fin[poz]==0){l++;st[poz]=fin[poz]=l;a[1][l]=x;}
else {l++;a[2][fin[poz]]=l;a[1][l]=x;fin[poz]=l;}
}
if(y==2){poz=x%q;
z=st[poz];
while(z!=0)
{if(a[1][z]==x)a[1][z]=0;
z=a[2][z];
}
}
if(y==3){poz=x%q;
z=st[poz];ok=0;
for(j=z;j<=fin[poz]&&j!=0;j=a[2][j]){if(a[1][j]==x){printf("1\n");ok=1;break;}}
if(ok==0)printf("0\n");
}
}
fclose(stdin);fclose(stdout);
return 0;
}