Pagini recente » Cod sursa (job #2105185) | Cod sursa (job #1867639) | Cod sursa (job #603775) | Cod sursa (job #1958545) | Cod sursa (job #2815933)
#include <fstream>
#include <map>
#include <algorithm>
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
int n;
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;
}