Pagini recente » Cod sursa (job #2311206) | Cod sursa (job #2835680) | Cod sursa (job #2453752) | Istoria paginii runda/happybirthday/clasament | Cod sursa (job #2657348)
#include <fstream>
#include <vector>
#include <stdio.h>
using namespace std;
#define MAX_N 1000000
#define MOD 666013
ifstream cin ( "hashuri.in" );
ofstream cout ( "hashuri.out" );
vector<int> myHash[MOD];
bool cauta( int x ) {
int cod = x % MOD;
unsigned int i = 0;
while ( i < myHash[cod].size() && myHash[cod][i] != x )
i++;
return i < myHash[cod].size();
}
void adauga( int x ) {
int cod = x % MOD;
unsigned int i = 0;
while ( i < myHash[cod].size() && myHash[cod][i] != x )
i++;
if ( i == myHash[cod].size() )
myHash[cod].push_back(x);
}
void sterge( int x ) {
int cod = x % MOD;
unsigned int i = 0;
while ( i < myHash[cod].size() && myHash[cod][i] != x )
i++;
if ( i < myHash[cod].size() )
myHash[cod].erase(myHash[cod].begin() + i);
}
int main() {
int n, op, x, i;
cin >> n;
for ( i = 1; i <= n; i++ ) {
cin >> op >> x;
if ( op == 1 )
adauga(x);
else if ( op == 2 )
sterge(x);
else
cout << cauta(x) << "\n";
}
return 0;
}