Cod sursa(job #697845)

Utilizator Robert29FMI Tilica Robert Robert29 Data 29 februarie 2012 11:21:17
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.6 kb
#include<stdio.h>
#define h1 666013
#define h2 666019
FILE*f=fopen("hashuri.in","r");
FILE*g=fopen("hashuri.out","w");
int t,op,x,H1[h1+2],H2[h2+2];
int main()
{
	fscanf(f,"%d",&t);
	for(int i=1;i<=t;++i)
	{
		fscanf(f,"%d%d",&op,&x);
		
		if(op==1)
		{
			if(H1[x%h1]==0||H2[x%h2]==0)
			{
				H1[x%h1]++;
				H2[x%h2]++;
			}
		}
		else if(op==2)
		{
			if(H1[x%h1]&&H2[x%h2])
			{
				H1[x%h1]--;
				H2[x%h2]--;
			}
		}else
		{
			if(H1[x%h1]&&H2[x%h2])
				fprintf(g,"1\n");
			else
				fprintf(g,"0\n");
		}
		
		
	}
	
	
	
	
	fclose(f);
	fclose(g);
	return 0;
}