Pagini recente » Cod sursa (job #541097) | Cod sursa (job #2326805) | Cod sursa (job #329871) | Cod sursa (job #2624049) | Cod sursa (job #1737763)
#include <fstream>
#include <vector>
#define VAL 200001
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int N, i;
int op, x;
vector<int> v[VAL];
vector<int>::iterator it;
int cauta(int x)
{
int lst;
lst=x % VAL;
for (it=v[lst].begin(); it!=v[lst].end(); it++)
if (*it==x)
return 1;
return 0;
}
void insereaza(int x)
{
int lst;
lst=x % VAL;
if (cauta(x)==0)
v[lst].push_back(x);
}
void sterge(int x)
{
int lst;
lst=x % VAL;
for (it=v[lst].begin(); it!=v[lst].end(); it++)
{
if (*it==x)
{
v[lst].erase(it);
return;
}
}
}
int main()
{
fin >> N;
for (i=1; i<=N; i++)
{
fin >> op >> x;
if (op==1)
insereaza(x);
if (op==2)
sterge(x);
if (op==3)
fout << cauta(x) << '\n';
}
fin.close();
fout.close();
return 0;
}