Pagini recente » Cod sursa (job #893743) | Cod sursa (job #918094) | Cod sursa (job #772591) | Cod sursa (job #1008977) | Cod sursa (job #1690397)
#include<fstream>
#include<vector>
#define key 25025
using namespace std;
vector<int> G[key+2];
int n, op, x;
vector<int>::iterator find_hash(int x)
{
int listt=x%key;
vector<int>::iterator it;
for(it=G[listt].begin(); it!=G[listt].end(); it++)
{
if(*it==x)
return it;
}
return G[listt].end();
}
void insert_hash(int x)
{
int listt=x%key;
if(find_hash(x)==G[listt].end())
G[listt].push_back(x);
}
void erase_hash(int x)
{
int listt=x%key;
vector<int>::iterator it;
it=find_hash(x);
if(it!=G[listt].end())
G[listt].erase(it);
}
ifstream in("hashuri.in");
ofstream out("hashuri.out");
int main()
{
in>>n;
for(;n--;)
{
in>>op>>x;
if(op==1)
{
insert_hash(x);
continue;
}
if(op==2)
{
erase_hash(x);
continue;
}
find_hash(x)!=G[x%key].end()?out<<"1\n":out<<"0\n";
}
return 0;
}