Pagini recente » Borderou de evaluare (job #2807223) | Borderou de evaluare (job #2899963) | Cod sursa (job #1274521) | Borderou de evaluare (job #3136095) | Cod sursa (job #2129722)
#include <fstream>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n,m,caz,i,idx,j,x,prim=666013,tabrest[666020];
struct elemente
{
int valoare,inapoila;
} v[1000010];
int srch(int x)
{
int rest=x%prim;
int poz=tabrest[rest];
while(poz)
{
if(x==v[poz].valoare)
return poz;
poz=v[poz].inapoila;
}
return 0;
}
void pune(int x)
{
int rest=x%prim;
if(srch(x)!=0)
return;
++idx;
v[idx].valoare=x;
v[idx].inapoila=tabrest[rest];
tabrest[rest]=idx;
}
void sterge(int x)
{
int rest=x%prim;
int poz=srch(x);
if(poz==0)
return;
v[poz].valoare=-1;
}
int main()
{
fin>>n;
for(i=1;i<=n;++i)
{
fin>>caz>>x;
if(caz==1)
pune(x);
else
if(caz==2)
sterge(x);
else
if(caz==3)
{
if(srch(x))
fout<<1<<"\n";
else
fout<<0<<"\n";
}
}
return 0;
}