Pagini recente » Cod sursa (job #2351966) | Cod sursa (job #36823) | Cod sursa (job #2485505) | Cod sursa (job #2688374) | Cod sursa (job #2268203)
#include <bits/stdc++.h>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int N = 100003; /// un numar prim utilizat in tabela de dispersie ( tabela hash )
struct nod
{
int info;
nod *nxt;
};
nod *H[N],*p,*q;
int n,o,x,h;
int main()
{
f>>n;
for(;n;n--)
{
f>>o>>x;
h=x%N;
for(p=H[h];p;p=p->nxt)
if(p->info==x)
break;
if(o==1&&p==NULL)
{
q=new nod;
q->info=x;
q->nxt=H[h];
H[h]=q;
}
else if(o==2&&p!=NULL)
{
p->info=H[h]->info;
q=H[h];
H[h]=q->nxt;
delete q;
}
else if(o==3)
{
if(p==NULL)
g<<"0\n";
else
g<<"1\n";
}
}
return 0;
}