Cod sursa(job #764728)
#include <fstream>
#include <stdlib.h>
#include <vector>
using namespace std;
const int M = 666013;
vector<int> hash[M];
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
inline vector<int>::iterator cauta(int );
//int op3 (int);
//lista *cauta ( int );
int main()
{
int i,n,op,x,indx;
// lista *q,*aux,*aux1;
fin>>n;
for(i=0;i<n;i++)
{
fin>>op>>x;
vector<int>::iterator it;
indx=x%M;
switch (op)
{
case 3:
// vector<int>::iterator it;
it=cauta(x);
if ( it!=hash[indx].end() )
fout<<"1\n";
else
fout<<"0\n";
break;
case 2:
// vector<int>::iterator itr;
it=cauta(x);
if (it!=hash[indx].end())
hash[indx].erase(it);
break;
case 1:
//vector<int>::iterator itrt;
it=cauta(x);
if (it==hash[indx].end())
hash[indx].push_back(x);
break;
}
}
fin.close();
fout.close();
return 0;
}
inline vector<int>::iterator cauta(int x)
{
vector<int>::iterator it;
int index=x%M;
for(it=hash[index].begin();it!=hash[index].end();it++)
if(*it==x)
return it;
return hash[index].end();
}