Cod sursa(job #632093)

Utilizator sanzianaioneteIonete Sanziana sanzianaionete Data 10 noiembrie 2011 12:04:41
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.71 kb
#include <cstdio>
#include <vector>
#define Mod 666013
using namespace std;
vector<int> h[Mod];
vector<int>::iterator it;
int i,n,op,x,ind;
bool ok;
vector<int> :: iterator findv(int x)
{
	for(it=h[ind].begin();it<h[ind].end();it++)
		if(*it==x) return it;
	return it;
}
int main()
{
	freopen("hashuri.in","r",stdin);
	freopen("hashuri.out","w",stdout);
	scanf("%d\n",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d\n",&op,&x);
		ind=x%Mod;
		it=findv(x);
		if (it==h[ind].end()) ok=false;
		else ok=true;
		if(op==1&&!ok) h[ind].push_back(x);
		if(op==2&&ok) h[ind].erase(it);
		if(op==3)
		{
        	if(ok) printf("1\n"); 
		    else printf("0\n");
	}
	fclose(stdin);fclose(stdout);
	return 0;
}