Pagini recente » Cod sursa (job #439978) | Cod sursa (job #1619369) | Cod sursa (job #1642342) | Cod sursa (job #1812267) | Cod sursa (job #581797)
Cod sursa(job #581797)
#include <stdio.h>
const int mod=666013;
int i,n,x,t,res,ok;
struct nod{int x; nod *next;};
nod *G[mod];
int main(void)
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for (i=1;i<=n;i++)
{
scanf("%d%d",&t,&x);
res=x%mod;
if (t==1)
{
ok=0;
nod *it=new nod;
it=G[res];
while (it)
{
if (it->x==x) {ok=1; break;}
it=it->next;
}
if (!ok)
{
it=new nod;
it->x=x;
it->next=G[res];
G[res]=it;
}
}
if (t==2)
{
ok=0;
nod *it=new nod;
it=G[res];
if (it && it->x==x) ok=1;
while (it && it->next)
{
if (it->next->x==x) {ok=1; break;}
it=it->next;
}
if (ok)
{
if (!G[res]->next) G[res]=NULL;
else
{
if (it->next->next)
it->next=it->next->next;
else it->next=NULL;
}
}
}
if (t==3)
{
ok=0;
nod *it=new nod;
it=G[res];
while (it)
{
if (it->x==x) {ok=1; break;}
it=it->next;
}
printf("%d\n",ok);
}
}
return 0;
}