Cod sursa(job #1773391)

Utilizator dodecagondode cagon dodecagon Data 7 octombrie 2016 19:51:59
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1.26 kb
#include <stdio.h>
#include <unordered_map>

using namespace std;

int n,op,x;
unordered_map<int,int> mp;

const int buff_size=4096;
char buff[buff_size];
int _i=buff_size;


int next_int(FILE * in)
{
    char x,y,k=1;
    int z=0;
   
   if (_i==buff_size)
    y=fread(buff,buff_size,1,in),_i=0;
      
     x=1;
 
      while ((x<48 || x> 57) && x!='-')
         {  
          x=buff[_i];
          _i++;
          if (_i==buff_size)
             {
              y=fread(buff,buff_size,1,in);
              _i=0;
             }
         }
 
      while (x>=48 && x<=57 || x=='-')
      {
        if (x=='-') 
          k=-1; else 
        z=(z<<1)+(z<<3)+x-48;
        x=buff[_i];
        _i++;
         if (_i==buff_size)
           {
               y=fread(buff,buff_size,1,in);
               _i=0;
             }
      }
 
    return z*k;
}

int main(int argc, char const *argv[])
{

   freopen("hashuri.in","r",stdin);
   freopen("hashuri.out","w",stdout);
  
	n=next_int(stdin);

	while (n--)
	{
		op=next_int(stdin);
		x=next_int(stdin);
		if (op==1)
			mp.insert(make_pair(x,1)); else 
		if (op==2)
		{
			
				if (mp.find(x)!=mp.end() && mp[x]>0)
					mp[x]--;
		} else 
		{
			if (mp[x]==0)
				puts("0"); else 
			puts("1");
		}

	}

	fclose(stdin);
	fclose(stdout);
	
	return 0;
}