Pagini recente » Cod sursa (job #1649130) | Cod sursa (job #1572068) | Cod sursa (job #2971326) | Cod sursa (job #1176887) | Cod sursa (job #2742224)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
#define k 666013
vector <int> V[k];
vector<int>::iterator cauta(int x)
{
int h=x%k;
vector<int>::iterator i;
for(i=V[h].begin();i!=V[h].end();i++)
if(*i==x)
return i;
return V[h].end();
}
void adauga(int x)
{
int h=x%k;
if(cauta(x)==V[h].end())
V[h].push_back(x);
}
void sterge(int x)
{
int h=x%k;
vector<int>::iterator i=cauta(x);
if (i!=V[h].end())
V[h].erase(i);
}
int main()
{
int n,x;
char op;
f>>n;
for(int i=0;i<n;i++)
{
f>>op>>x;
if(op=='1'){
adauga(x);
}
else if(op=='2'){
sterge(x);
}
else{
if(cauta(x)!=V[x%k].end())
g<<1<<'\n';
else g<<0<<'\n';
}
}
return 0;
}