Cod sursa(job #1977056)

Utilizator pepsiM4A1Ozturk Arif pepsiM4A1 Data 4 mai 2017 22:03:33
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.85 kb
#include <cstdio>
#include <unordered_map>
using namespace std;
const int DIM=100000;
unordered_map<int,int>ap;
char buff[DIM];
int poz=DIM-1;
void citeste(int &nr)
{
    nr=0;
    while(!('0'<=buff[poz]&&buff[poz]<='9'))
    {
        if(++poz==DIM) fread(buff,1,DIM,stdin),poz=0;
    }
    while('0'<=buff[poz]&&buff[poz]<='9')
    {
        nr=nr*10 + buff[poz]-'0';
        if(++poz==DIM) fread(buff,1,DIM,stdin),poz=0;
    }
}
int main()
{
    freopen ("hashuri.in","r",stdin);
    freopen ("hashuri.out","w",stdout);
    int n;
    citeste(n);
    for(;n>0;--n)
    {
        int tip,val;
        citeste(tip),citeste(val);
        if(tip==1) ap[val]++;
        else if(tip==2&&ap[val]>0) --ap[val];
        else if(tip==3)
        {
            if(ap[val]>0) printf("1\n");
            else printf("0\n");
        }
    }
}