Cod sursa(job #3129990)

Utilizator BranckhiusIon Dragos-Constantin Branckhius Data 16 mai 2023 16:11:50
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include<iostream>
#include<fstream>
#include<unordered_map>
using namespace std;
int main() {
	ifstream f("hashuri.in");
	ofstream g("hashuri.out");
	int n,i,op,nr;
	unordered_map<int, int> hash;
	f >> n;
	for (i = 0;i < n;i++) {
		f >> op;
		f >> nr;
		if (op == 1) {
			if (hash.count(nr) == 0) {
				hash[nr] = 1;
			}
		}
		if (op == 2) {
			if (hash.count(nr) == 1) {
				hash.erase(nr);
			}
		}
		if (op == 3) {
			if (hash.count(nr) !=0) {
				g << "1" << endl;
			}
			else {
				g << "0" << endl;
			}
		}
	}
}