Cod sursa(job #294533)

Utilizator whiskeyOzzy Osbourne whiskey Data 2 aprilie 2009 16:56:13
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#include <stdio.h>
#include <map>
using namespace std;

int n;
map<int, int> mult;

int main()
{
	int i, op, x;
	FILE *fin = fopen("hashuri.in", "r");
	FILE *fout = fopen("hashuri.out", "w");
	fscanf(fin, "%d", &n);
	for (i = 1; i <= n; ++i)
	{
		fscanf(fin, "%d%d", &op, &x);
		if (op == 1)	//add
		{
			if (mult.find(x) == mult.end())
			{
				mult[x] = x;
			}
		}
		else if (op == 2)	//remove
		{
			mult.erase(x);
		}
		else	//search
		{
			if (mult.find(x) != mult.end())
			{
				fprintf(fout, "1\n");
			}
			else
			{
				fprintf(fout, "0\n");
			}
		}
	}
	fclose(fin);
	fclose(fout);
	return 0;
}