Cod sursa(job #1606835)

Utilizator BFlorin93Balint Florin-Lorand BFlorin93 Data 20 februarie 2016 16:48:48
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.89 kb
// Hashing.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <unordered_map>
#include <fstream>

using namespace std;

int main()
{
	ifstream inFile("hashuri.in");
	ofstream outFIle("hashuri.out");

	unordered_map<int, bool> hashMap;
	int n, op, val;

	inFile >> n;
	//cin >> n;
	for (int i = 0; i < n; i++) {
		inFile >> op >> val;
		//cin >> op >> val;
		switch (op) {
			case 1:
				if (hashMap.find(val) == hashMap.end()) {
					hashMap[val] = true;
				}
				break;
			case 2:				
					hashMap.erase(val);				
				break;
			case 3:
				if (hashMap.find(val) != hashMap.end()) {
					outFIle << 1 << endl;
					//cout << "out" <<  1 << endl;
				}
				else {
					outFIle << 0;
					//cout << "out" << 0 << endl;
				}
				break;
		}
	}

	outFIle.close();

	return 0;
}