Cod sursa(job #2623463)

Utilizator CosminMorarMorar Cosmin Andrei CosminMorar Data 3 iunie 2020 11:08:54
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n, operatie, nr;

class hashmap {
private:
	unordered_set<int> v[100001];

public:
	void add(int x) {
		v[x % 100001].insert(x);
	}

	void del(int x) {
		v[x % 100001].erase(x);
	}

	bool have(int x) {
		return (v[x % 100001].find(x) != v[x % 100001].end());
	}
} hmap;

int main() {
	fin >> n;
	for (int i = 1; i <= n; i++) {
		fin >> operatie >> nr;
		if (operatie == 1)
			hmap.add(nr);
		else if (operatie == 2)
			hmap.del(nr);
		else
			fout << hmap.have(nr) << '\n';
	}
    return 0;
}