Cod sursa(job #2721328)

Utilizator FrostfireMagirescu Tudor Frostfire Data 11 martie 2021 18:36:32
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.33 kb
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <unordered_map>
#pragma GCC optimize("O3")

using namespace std;

ofstream fout("hashuri.out");

class InParser {
private:
	FILE *fin;
	char *buff;
	int sp;
 
	char read_ch() {
		++sp;
		if (sp == 4096) {
			sp = 0;
			fread(buff, 1, 4096, fin);
		}
		return buff[sp];
	}
 
public:
	InParser(const char* nume) {
		fin = fopen(nume, "r");
		buff = new char[4096]();
		sp = 4095;
	}
	
	InParser& operator >> (int &n) {
		char c;
		while (!isdigit(c = read_ch()) && c != '-');
		int sgn = 1;
		if (c == '-') {
			n = 0;
			sgn = -1;
		} else {
			n = c - '0';
		}
		while (isdigit(c = read_ch())) {
			n = 10 * n + c - '0';
		}
		n *= sgn;
		return *this;
	}
	
	InParser& operator >> (long long &n) {
		char c;
		n = 0;
		while (!isdigit(c = read_ch()) && c != '-');
		long long sgn = 1;
		if (c == '-') {
			n = 0;
			sgn = -1;
		} else {
			n = c - '0';
		}
		while (isdigit(c = read_ch())) {
			n = 10 * n + c - '0';
		}
		n *= sgn;
		return *this;
	}
};

int q;
unordered_map <int, bool> M;

int main()
{
	InParser fin("hashuri.in");
	fin >> q;
	while(q--)
		{	int type, x;
			fin >> type >> x;
			if(type == 1)
				M[x] = 1;
			else if(type == 2)
				M[x] = 0;
			else
				fout << M[x] << '\n';
		}
	return 0;
}