Cod sursa(job #2990940)

Utilizator mati.coldea@gmail.comMatei Coldea [email protected] Data 8 martie 2023 19:47:11
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.71 kb
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
string s;
string s2;
vector<int> pi(100000);

unordered_set<int> mp;

int main() {

	ios_base::sync_with_stdio(false);
	fin.tie(NULL);
	int n;
	fin >> n;
	int nr = 0;
	for (int i = 1; i <= n; i++) {
		int cer;
		fin >> cer;
		if (cer == 1) {
			int x;
			fin >> x;
			mp.insert(x);
			//nr++;
		}

		if (cer == 2) {
			int x;
			fin >> x;
			mp.erase(x);


		}
		if (cer == 3) {
			int x;

			fin >> x;
			if (mp.find(x) != mp.end()) {
				fout << 1<<'\n';
			}
			else {
				fout << 0 << '\n';
			}
		}
	}

	



	fin.close();
	fout.close();
}