Cod sursa(job #425714)

Utilizator slayer4uVictor Popescu slayer4u Data 25 martie 2010 23:36:50
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

#define P 60000

multiset <int> hash[P];

long n, code, x, mod;

int main()
{
	freopen ("hashuri.in", "rt", stdin);
	freopen ("hashuri.out", "wt", stdout);

	scanf("%ld", &n);
	for (long i = 0; i < n; ++i)
	{
		scanf("%ld %ld", &code, &x);
		mod = x % P;
		if (code == 3)
			printf("%ld\n", hash[mod].find(x) != hash[mod].end());
		else
		if (code == 1)
			hash[mod].insert(x);
		else
			if (hash[mod].find(x) != hash[mod].end())
				hash[mod].erase(hash[mod].find(x));
	}

	return 0;
}