Cod sursa(job #710747)

Utilizator mihaibogdan10Mihai Bogdan mihaibogdan10 Data 10 martie 2012 17:59:45
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.52 kb
#include<cstdio>
using namespace std;

const int M1 = 45007, M2 = 45013; int H1[M1], H2[M2];

int Cauta(int x){
	return H1[x % M1] && H2[x % M2] ? 1 : 0;
}

int main(){
	freopen ("hashuri.in", "r", stdin), freopen("hashuri.out", "w", stdout);
	
	int i, n, x, op;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d %d", &op, &x);
		if (op == 1) 
			if (Cauta(x) == 0) H1[x % M1]++, H2[x % M2]++;
		if (op == 2) 
			if (Cauta(x) == 1) H1[x % M1]--, H2[x % M2]--;
		if (op == 3) printf("%d\n", Cauta(x));
	}
	return 0;
}