Cod sursa(job #607317)

Utilizator cosminx2003Cosmin Clapon cosminx2003 Data 11 august 2011 17:07:11
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.72 kb
#include <iostream.h>
#include <fstream.h>
#define M 19777

ifstream f("hashuri.in");
ofstream g("hashuri.out");

using namespace std;
uint8_t H[M][M],P=19777;


void hAdd(int x);
void hDelete(int x);
int hCheck(int x);

int main()
{
	int n,i,op,x;
	
	f>>n;
	
	for(i=1;i<=n;i++)
	{
		f>>op>>x;
		switch(op)
		{
			case 1:
				hAdd(x);
			break;
			case 2:
				hDelete(x);
			break;
			case 3:
				g<<hCheck(x)<<"\n";
			break;
		}
		/*for(int j=0;j<30;j++)
			cout<<H[0][j]<<" ";
		cout<<endl;*/
	}
	
	f.close();
	g.close();
	return 0;
}

void hAdd(int x)
{
	H[x/P][x%P]=1;
}

void hDelete(int x)
{
	H[x/P][x%P]=0;
}

int hCheck(int x)
{
	if(H[x/P][x%P])
		return 1;
	return 0;
}