Cod sursa(job #432168)

Utilizator NemultumituMatei Ionita Nemultumitu Data 1 aprilie 2010 22:12:01
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include <cstdio>
#include <vector>
#define q 4000001
using namespace std;
int n;
bool hash[q];

void push(int x)
{
	hash[x%q]=1;
}

void pop(int x)
{
	hash[x%q]=0;
}

void query(int x)
{
	printf("%d\n",hash[x%q]);
}

int main()
{
	freopen ("hashuri.in","r",stdin);
	freopen ("hashuri.out","w",stdout);
	scanf("%d",&n);
	int x,y;
	while (n--)
	{
		scanf("%d%d",&y,&x);
		if (y==1)
			push(x);
		if (y==2)
			pop(x);
		if (y==3)
			query(x);
	}
	return 0;
}