Pagini recente » Cod sursa (job #3226190) | Cod sursa (job #632902) | Cod sursa (job #1969200) | Cod sursa (job #975430) | Cod sursa (job #2617715)
#include <bits/stdc++.h>
using namespace std;
vector<int> v[666013];
int n;
vector<int> :: iterator gaseste(int x){
int pozitie = x % 666013;
for (vector<int> :: iterator it = v[pozitie].begin(); it != v[pozitie].end(); it++)
if (*it == x)
return it;
return v[pozitie].end();
}
void insereaza(int x){
int pozitie = x % 666013;
if(gaseste(x) == v[pozitie].end())
v[pozitie].push_back(x);
}
void sterge(int x){
int pozitie = x % 666013;
if (gaseste(x) != v[pozitie].end())
v[pozitie].erase(gaseste(x));
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
cin >> n;
for (int i = 0; i < n; i++){
int op, x;
cin >> op >> x;
if (op == 1)
insereaza(x);
else {
if (op == 2)
sterge(x);
else
if (gaseste(x) != v[x % 666013].end())
cout << "1" << '\n';
else
cout << "0" << '\n';
}
}
return 0;
}