Cod sursa(job #1750040)

Utilizator delia_ioanaCeapa Delia Ioana delia_ioana Data 29 august 2016 14:58:13
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.54 kb
#include <stdio.h>
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
	freopen("hashuri.in", "r", stdin);
	freopen("hashuri.out", "w", stdout);
	int N, a, b;
	unordered_map <int,int> mymap;
	scanf("%d", &N);

	for (int i = 0; i < N; i ++) {
		scanf("%d %d", &a, &b);
		
		if (a == 1 && mymap.find(b) == mymap.end())
			mymap.insert(make_pair(b, i));
		else if (a == 2 && mymap.find(b) != mymap.end())
			mymap.erase(b);
		else if (a == 3) {
			int val = (mymap.find(b) != mymap.end);
			printf("%d\n", val);
		}
	}
	return 0;
}