Cod sursa(job #2702612)

Utilizator DragosC1Dragos DragosC1 Data 4 februarie 2021 22:22:39
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <fstream>
#include <unordered_map>
using namespace std;
 
int n, cnt;
unordered_map <int, int> h;
 
int main() {
    ios::sync_with_stdio(0);
	int i, tip, x;
    
    ifstream f("hashuri.in");
    ofstream g("hashuri.out");
	f >> n;
	for (i = 1; i <= n; i++) {
		f >> tip >> x;
		if (tip == 1 && h.find(x) == h.end()) h[x] = ++cnt;
		if (tip == 2) h.erase(x);
		if (tip == 3) g << (h.find(x) != h.end()) << '\n';
	}
	f.close();
	g.close();
	return 0;
}