Cod sursa(job #808258)
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
#define mod 666013
struct nod
{ long info;
nod *urm;
} *lista[mod];
ifstream in("hashuri.in");
ofstream out("hashuri.out");
long n;
void insert (long x)
{
long k;
k=x%mod;
nod *p= new nod;
p ->info=x;
p->urm=lista[k];
lista[k]=p;
}
long find (long x)
{
long k=x%mod;
if ( lista[k]==NULL) return 0 ;
if (lista[k]->info==x) return 1;
nod *p=lista[k];
while (p->urm)
{
p=p->urm;
if (p->info==x) return 1;
}
return 0;
}
void deletes (long x)
{
long k=x%mod;
nod *p;
nod *q;
if ( lista[k]->info==x)
{
p=lista[k];
lista[k]=lista[k]->urm;
delete p ;
return ;
}
for (p=lista[k];p->urm;p=p->urm)
{
if (p->urm->info==x)
{
q=p->urm;
p->urm=q->urm;
delete q ;
return;
}
}
}
int main()
{ long c;
long x;
in>>n;
while (n--)
{
in>>c>>x;
if (c==1)
{
if (find(x)==0) insert(x);
}
else
if (c==2)
{
if (find(x)==1) deletes(x);
}
else
if (c==3)
out<<find(x)<<endl;
}
return 0;
}