Pagini recente » Cod sursa (job #2798784) | Cod sursa (job #1023058) | Cod sursa (job #2580097) | Cod sursa (job #66924) | Cod sursa (job #1112387)
#include <fstream>
#include <vector>
#include <algorithm>
#define modulo 666013
using namespace std;
ifstream in ( "hashuri.in" ) ;
ofstream out ( "hashuri.out" ) ;
vector<int> vect[modulo] ;
int n , tip , nr , i ;
int hash_function ( int nr )
{
return ( 34181*nr + 564792 ) % modulo ;
}
void insert_function ( int nr )
{
int key = hash_function(nr) ;
if ( std::find( vect[key].begin() , vect[key].end() , nr ) != vect[key].end() ) { ; }
else { vect[key].push_back(nr) ; }
}
void erase_function ( int nr )
{
int key = hash_function(nr) ;
if ( std::find( vect[key].begin() , vect[key].end() , nr ) != vect[key].end() )
{
vect[key].erase( std::remove( vect[key].begin() , vect[key].end() , nr ) , vect[key].end() ) ;
}
}
void call_function ( int nr )
{
int key = hash_function(nr) ;
if ( std::find( vect[key].begin() , vect[key].end() , nr ) != vect[key].end() ) { out << 1 << "\n" ; }
else { out << 0 << "\n" ; }
}
int main()
{
in >> n ;
for ( i = 1 ; i <= n ; i ++ )
{
in >> tip >> nr ;
if ( tip == 1 )
{
insert_function(nr) ;
}
else if ( tip == 2 )
{
erase_function(nr) ;
}
else
{
call_function(nr) ;
}
}
return 0;
}