Pagini recente » Cod sursa (job #2618986) | Cod sursa (job #277909) | Cod sursa (job #2998584) | Cod sursa (job #44903) | Cod sursa (job #581804)
Cod sursa(job #581804)
#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) G[res]=NULL;
else
while (it && it->next)
{
if (it->next->x==x) {ok=1; break;}
it=it->next;
}
if (ok)
{
nod *nou=it->next;
it->next=it->next->next;
delete it;
}
}
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;
}