Pagini recente » Cod sursa (job #2066480) | Cod sursa (job #1737237) | Cod sursa (job #1386265) | Cod sursa (job #352526) | Cod sursa (job #550406)
Cod sursa(job #550406)
#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;
}