Cod sursa(job #1429777)

Utilizator dinuandAndrei-Mario Dinu dinuand Data 7 mai 2015 02:19:03
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.52 kb
#include <iostream>
#include <fstream>
#include <unordered_map>

using namespace std;

ifstream in("hashuri.in");
ofstream out("hashuri.out");

int main()
{
	int N, type, x, value = 0;

	unordered_map<int, int> hashTable;
	in >> N;
	for (int i = 1; i <= N; i++) {
		in >> type >> x;

		if (type == 1 && hashTable.find(x) == hashTable.end()) hashTable[x] = ++value;
		if (type == 2 && hashTable.find(x) != hashTable.end()) hashTable.erase(x);
		if (type == 3) out << (hashTable.find(x) != hashTable.end()) << '\n'; 
	} 

	return 0;
}