Pagini recente » Cod sursa (job #2758861) | Cod sursa (job #650693) | Cod sursa (job #1433341) | Cod sursa (job #2542476) | Cod sursa (job #2815934)
#include <fstream>
#include <map>
#include <algorithm>
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
int n;
std::unordered_map< int , int > v;
int main()
{
fin>>n;
for(int i=1; i<=n; i++)
{
int cer;
fin>>cer;
switch(cer)
{
case(1):
{
int x;
fin>>x;
map<int,int>::iterator poz=v.find(x);
if(poz==v.end())
{
v.insert({x,1});
}
else
{
poz->second++;
}
break;
}
case(2):
{
int x;
fin>>x;
map<int,int>::iterator poz=v.find(x);
if(poz!=v.end())
{
poz->second--;
if(poz->second==0)
{
v.erase(x);
}
}
break;
};
case(3):
{
int x;
fin>>x;
map<int,int>::iterator poz=v.find(x);
if(poz==v.end())
{
fout<<"0\n";
}
else
{
fout<<"1\n";
}
};
};
}
return 0;
}