Pagini recente » Cod sursa (job #2417744) | Cod sursa (job #2562083) | Cod sursa (job #713000) | Cod sursa (job #1284320) | Cod sursa (job #1123604)
#include<fstream>
#include<vector>
#define FIN "hashuri.in"
#define FOUT "hashuri.out"
#define MOD 666013
using namespace std;
ifstream f(FIN);
ofstream g(FOUT);
vector<int> h[MOD];
int n;
vector<int>::iterator hash_find(int x)
{
int list = x % MOD;
vector<int>::iterator it;
for(it=h[list].begin();it!=h[list].end();it++)
{
if(*it == x)
{
return it;
}
}
return h[list].end();
}
void hash_insert(int x)
{
int list = x % MOD;
if(hash_find(x) == h[list].end())
h[list].push_back(x);
}
void hash_erase(int x)
{
int list = x % MOD;
vector<int>::iterator it = hash_find(x);
if(it != h[list].end())
h[list].erase(it);
}
int main()
{
int x,y;
f>>n;
for(int i=1;i<=n;i++)
{
f>>x;
f>>y;
switch(x)
{
case 1:
hash_insert(y);
break;
case 2:
hash_erase(y);
break;
case 3:
g<<(hash_find(y)!=h[y%MOD].end())<<endl;
break;
}
}
return 0;
}