Pagini recente » Cod sursa (job #157391) | Cod sursa (job #1329577) | Cod sursa (job #2876558) | Cod sursa (job #1110240) | Cod sursa (job #1994613)
#include <fstream>
#include <vector>
#define mod 666013
using namespace std;
ofstream fout("hashuri.out");
ifstream fin("hashuri.in");
int n,i,a,b;
vector< int > v[1234580];
inline vector< int >::iterator cautaval( int x )
{
int aux = x % mod;
vector< int >::iterator it;
for( it = v[ aux ].begin() ; it != v[ aux ].end() ; it++ )
if( *it == x )
return it;
return v[ aux ].end();
}
void insereaza( int x )
{
int aux = x % mod;
auto it = cautaval( x );
if( it == v[ aux ].end() )
v[ aux ].push_back( x );
}
void sterge( int x )
{
int aux = x % mod;
auto it = cautaval( x );
if( it != v[ aux ].end() )
v[ aux ].erase( it );
}
bool cauta( int x )
{
int aux = x % mod;
auto it = cautaval( x );
return ( it != v[ aux ].end() ) ;
}
int main()
{
fin>>n;
for( i = 1 ; i <= n ; i++ )
{
fin>>a>>b;
if( a == 1 )
insereaza( b );
if( a == 2 )
sterge( b );
if( a == 3 )
fout<<cauta( b )<<'\n';
}
}