Cod sursa(job #703619)

Utilizator Robert29FMI Tilica Robert Robert29 Data 2 martie 2012 13:14:00
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.78 kb
#include<stdio.h>
#include<vector>
using namespace std;
#define h 666013
FILE*f=fopen("hashuri.in","r");
FILE*g=fopen("hashuri.out","w");
int t,op,x;
vector <int> H[h+2];
int main()
{
	int j;
	fscanf(f,"%d",&t);
	for(int i=1;i<=t;++i)
	{
		fscanf(f,"%d%d",&op,&x);
		if(op==1)
		{
			
			for(j=0;j<H[x%h].size();++j)
				if(x==H[x%h][j])
					break;
			if(j==H[x%h].size())
				H[x%h].push_back (x);
		}
		else if(op==2)
		{
			vector<int>::iterator it,it1;
			it=H[x%h].begin();
			it1=H[x%h].end();
			for(;it!=it1;++it)
				if(x==*it)
				{
					H[x%h].erase(it);
					break;
				}
		}
		else
		{
			int ok=0;
			for(int j=0;j<H[x%h].size();++j)
				if(x==H[x%h][j])
					ok=1;
			fprintf(g,"%d\n",ok);	
		}
					
		
	}
	
	
	
	
	fclose(f);
	fclose(g);
	return 0;
}