Pagini recente » Cod sursa (job #2778335) | Cod sursa (job #1278771) | Cod sursa (job #3316120) | Cod sursa (job #1100495) | Cod sursa (job #2346840)
#include <stdio.h>
#define MOD 1000000
using namespace std;
struct nod{
int inf;
nod *urm;
}*l[1000*1000];
void adaug(nod *&u,int x){
nod *p;
p=new nod;
p->inf=x;
p->urm=u;
u=p;
}
void stergere(nod *&u,int x){
nod *p;
int ok=1;
if(u==NULL) ok=0;
if(ok==1){p=u;
if(p->inf==x){
u=u->urm;
delete p;
ok=0;
}
if(ok==1){while(p->urm&&p->urm->inf!=x)p=p->urm;
if(p->urm->inf==x){
nod *aux=p->urm;
p->urm=p->urm->urm;
delete aux;
}
}
}
}
int afis(nod *u,int x){
for(nod *p=u;p;p=p->urm) if(p->inf==x) return 1;
return 0;
}
int p,x,n;
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for(int k=1;k<=n;k++){
scanf("%d%d",&p,&x);
if(p==1){
adaug(l[x%MOD],x);
}
else if(p==2){
stergere(l[x%MOD],x);
}
else{
printf("%d\n",afis(l[x%MOD],x));
}
}
return 0;
}