Pagini recente » Cod sursa (job #2772243) | Cod sursa (job #269674) | Cod sursa (job #2385927) | Cod sursa (job #2385463) | Cod sursa (job #3163402)
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <vector>
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
unordered_map<int, vector<int> > hsh;
int n,op,arg;
int main()
{
fin>>n;
for(int k=1;k<=n;k++)
{
fin>>op>>arg;
if(op==1)
{
(hsh[arg%500009]).push_back(arg);
}
else if(op==2)
{
int carg=arg%500009;
if(hsh[carg].empty())
continue;
for(vector<int>::iterator ele=hsh[carg].begin();ele!=hsh[carg].end();ele++)
{
if(*ele==arg)
{
hsh[carg].erase(ele);
break;
}
}
}
else
{
bool test=false;
int carg=arg%500009;
if(hsh[carg].empty())
test=false;
for(vector<int>::iterator ele=hsh[carg].begin();ele!=hsh[carg].end() && test==false;ele++)
{
if(*ele==arg)
test=true;
}
fout<<test<<'\n';
}
}
return 0;
}