Cod sursa(job #550406)

Utilizator BitOneSAlexandru BitOne Data 9 martie 2011 14:45:52
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.7 kb
#include <list>
#include <fstream>
#include <cstdlib>
#include <algorithm>
#define MODULO 666733

using namespace std;
list< int > v[MODULO];
inline bool Exist( int x )
{
	int p=x%MODULO;
	return v[p].end() != find( v[p].begin(), v[p].end(), x );
}
inline void Delete( int x )
{
	int p=x%MODULO;
	v[p].remove(x);
}
inline void Add( int x )
{
	if( false == Exist(x) )
		v[x%MODULO].push_back(x);
}

int main( void )
{
	int N, op, x;
	ifstream in( "hashuri.in" );
	ofstream out( "hashuri.out" );
	for( in>>N; N; --N )
	{
		in>>op>>x;
		switch(op)
		{
			case 1 : Add(x); break;
			case 2 : Delete(x); break;
			case 3 : out<<Exist(x)<<'\n'; break;
		}
	}	
	return EXIT_SUCCESS;
}