Cod sursa(job #519467)
#include <stdio.h>
const int M=666013;
int N,c,x;
struct elem{
int inf;
elem *next;
} *H[M];
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
elem *p,*q;
for(scanf("%d",&N);N;N--)
{
scanf("%d %d",&c,&x);
for(p=H[x%M];p && p->inf!=x;p=p->next); //cautare
if(c==1 && p==NULL)
{
q=new elem;
q->inf=x; q->next=H[x%M];
H[x%M]=q;
continue;
}
if(c==2 && p!=NULL)
{
q=p;
p=p->next;
delete(q);
continue;
}
if(c==3)
{
if(p==NULL)
printf("0\n");
else printf("1\n");
}
}
}