Pagini recente » Cod sursa (job #7212) | Cod sursa (job #1715268) | Cod sursa (job #873207) | Cod sursa (job #132281) | Cod sursa (job #630733)
Cod sursa(job #630733)
#include <fstream>
#include <vector>
#define p 666013
using namespace std;
vector<int> h[p];
vector<int>::iterator cauta(long x)
{
vector<int>::iterator it;
for (it=h[x%p].begin(); it!=h[x%p].end(); it++)
if (*it==x)
return it;
return h[x%p].end();
}//cauta
void adauga(long x)
{
if (cauta(x)==h[x%p].end())
h[x%p].push_back(x);
}//adauga
void sterge(long x)
{
vector<int>::iterator it=cauta(x);
if (it!=h[x%p].end())
h[x%p].erase(it);
}//sterge
int main()
{
long n, o, x;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
fin>>n;
for (long i=0; i<n; i++)
{
fin>>o>>x;
if (o==1)
adauga(x);
if (o==2)
sterge(x);
if (o==3)
fout<<(cauta(x)!=h[x%p].end())<<"\n";
}//for i
return 0;
}//main