Pagini recente » Cod sursa (job #1328924) | Cod sursa (job #1626542) | Cod sursa (job #245042) | Cod sursa (job #1147798) | Cod sursa (job #2531151)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int MOD = 666013;
vector <int> v[MOD];
void add( int x ) {
int j = x % MOD;
vector<int>::iterator it;
it = v[j].begin();
while ( it != v[j].end() && *it != x ) {
it ++;
}
if ( it == v[j].end() )
v[j].push_back( x );
}
void sterge( int x ) {
int j = x % MOD;
vector<int>::iterator it;
it = v[j].begin();
while ( it != v[j].end() && *it != x ) {
it ++;
}
if ( it != v[j].end() ) {
v[j].erase( it );
}
}
int cautare( int x ) {
int j = x % MOD;
vector<int>::iterator it;
it = v[j].begin();
while ( it != v[j].end() && *it != x ) {
it ++;
}
return ( it != v[j].end() );
}
int main() {
ifstream fin( "hashuri.in" );
ofstream fout( "hashuri.out" );
int n, i, cer, x;
fin >> n;
for ( i = 0; i < n; i ++ ) {
fin >> cer >> x;
if ( cer == 1 ) {
add( x );
} else if ( cer == 2 ) {
sterge( x );
} else
fout << cautare( x ) << '\n';
}
return 0;
}