Cod sursa(job #1596122)

Utilizator dimavascan94VascanDumitru dimavascan94 Data 10 februarie 2016 20:10:57
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.55 kb
#include <iostream>
#include <set>
using namespace std;

int N, op, x;
set<int> theHash;

int main()
{
	freopen("hashuri.in", "r", stdin);
	freopen("hashuri.out", "w", stdout);
	cin >> N;
	while (N > 0)
	{
		scanf("%d%d",&op,&x);
		switch (op)
		{
			case 1://insert value, if does not exist
				theHash.insert(x);
				break;
			case 2://delete value, if exists
				theHash.erase(x);
				break;
			case 3://try to find the value, and print output
				printf("%d\n", (theHash.find(x) != theHash.end()));
				break;
		}
		N--;
	}

}