Cod sursa(job #1075259)

Utilizator sp3ct3rFMI Dima Robert sp3ct3r Data 8 ianuarie 2014 19:41:44
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.67 kb
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <unordered_set>
using namespace std;

int main()
{
	freopen("hashuri.in", "r", stdin);
	freopen("hashuri.out", "w", stdout);
	unordered_set<int> hash;

	int n, op, val;
	scanf("%d", &n);
	unordered_set<int>::const_iterator res;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &op);
		scanf("%d", &val);
		switch (op)
		{
		case 1:
			hash.insert(val);
			break;
		case 2:
			hash.erase(val);
			break;
		case 3:
			res = hash.find(val);
			if (res != hash.end())
			{
				printf("1\n");
			}
			else
			{
				printf("0\n");
			}
			break;
		default: break;
		}
	}

	return 0;
}