Pagini recente » Rating Popa Alexandru (PAlexandru) | Cod sursa (job #1252239) | Cod sursa (job #2306059)
#include<cstdio>
#define M 666013
typedef struct O
{
int I;
struct O *U;
}N;
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);
q->U=p->U;
continue;
}
printf("%d\n",o);
}
}