Pagini recente » Cod sursa (job #2686309) | Cod sursa (job #2349084) | Cod sursa (job #2691709) | Cod sursa (job #2746477) | Cod sursa (job #1035753)
#include <fstream>
#include <vector>
#define Mod 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int N;
vector < int > Hash[Mod];
inline vector < int >::iterator FindHash(int x)
{
int list = x % Mod;
vector<int>::iterator it;
for (it =Hash[list].begin(); it!=Hash[list].end(); ++it)
if (*it == x)return it;
return Hash[list].end();
}
inline void InsertHash(int x)
{
int list=x % Mod;
if ( FindHash(x)==Hash[list].end() ) Hash[list].push_back(x);
}
inline void EraseHash(int x)
{
int list = x % Mod;
vector<int>::iterator it = FindHash(x);
if (it != Hash[list].end() ) Hash[list].erase(it);
}
int main()
{
f>>N;
for (int i=1;i<=N;++i)
{
int tip,x;
f>>tip>>x;
if (tip==1)InsertHash(x);
if (tip==2)EraseHash(x);
if(tip==3)g<< (FindHash(x)!=Hash[x % Mod].end())<<'\n';
}
f.close();g.close();
return 0;
}