Pagini recente » Cod sursa (job #1177720) | Cod sursa (job #1882437) | Cod sursa (job #1701927) | Cod sursa (job #1379562) | Cod sursa (job #3172845)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector<int> v[100001];
const int R=10007;
bool exista(int x) {
int hash=x%R;
for (auto elem: v[hash]) {
if (elem==x) {
return true;
}
}
return false;
}
void adaug(int x) {
int hash = x%R;
if (!exista(x)) {
v[hash].push_back(x);
}
}
void sterg(int x) {
int hash=x%R;
for (auto it=v[hash].begin(); it!=v[hash].end(); ++it) {
if (*it==x) {
v[hash].erase(it);
break;
}
}
}
int main() {
int n, op, x;
fin >> n;
for (int i = 0; i < n; i++) {
fin >> op >> x;
if (op == 1) {
adaug(x);
}
if (op == 2) {
sterg(x);
}
if (op == 3) {
if (exista(x)==1) {
fout<<"1"<<'\n';
}
if (exista(x)==0) {
fout<<"0"<<'\n';
}
}
}
fin.close();
fout.close();
return 0;
}