Pagini recente » Cod sursa (job #2786469) | Cod sursa (job #191760) | Cod sursa (job #383487) | Cod sursa (job #383569) | Cod sursa (job #1072643)
#include <fstream>
#include <vector>
using namespace std;
ifstream cin( "hashuri.in" );
ofstream cout( "hashuri.out" );
int n;
vector<int> v[ 666013 ];
vector<int>::iterator cautare( int x )
{
int ind;
ind = x % 666013;
vector<int>::iterator it;
for ( it = v[ ind ].begin(); it != v[ ind ].end(); it++ )
if ( *it == x ) return it;
return v[ ind ].end();
}
void inserare( int x )
{
int ind;
ind = x % 666013;
if ( cautare( x ) == v[ ind ].end() )
v[ ind ].push_back( x );
}
void stergere( int x )
{
int ind;
ind = x % 666013;
vector<int>::iterator it;
it = cautare( x );
if ( it != v[ ind ].end() )
v[ ind ].erase( it );
}
int main()
{
int i, op, x, ind;
cin >> n;
for ( i = 1; i <= n; i++ )
{
cin >> op >> x;
if ( op == 1 )
{
inserare( x );
continue;
}
if ( op == 2 )
{
stergere( x );
continue;
}
ind = x % 666013;
cout << ( cautare( x ) != v[ ind ].end() ) << '\n';
}
}