Pagini recente » Cod sursa (job #1386456) | Cod sursa (job #128561) | Rating Pavel Andrei George (andreipavel213) | Cod sursa (job #1550646) | Cod sursa (job #1312229)
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
#define nnn 700000
int n,op,nr,k;
vector<int> a[nnn];
inline vector<int>::iterator cauta(int nr)
{k=nr%nnn;
vector<int>::iterator it;
for( it=a[k].begin(); it!=a[k].end(); it++)
if(*it == nr)
return it;
return a[k].end();
}
inline void adauga(int nr)
{k=nr%nnn;
if(cauta(nr) == a[k].end())
a[k].push_back(nr);
}
inline void sterge(int nr)
{k=nr%nnn;
vector<int>::iterator it = cauta(nr);
if( it!=a[k].end())
a[k].erase(it);
}
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
for(f>>n;n;n--)
{
f>>op>>nr;
if(op==1) adauga(nr);
else if(op==2) sterge(nr);
else g<< (cauta(nr) != a[nr%nnn].end())<<"\n";
}
f.close();
g.close();
return 0;
}