Pagini recente » Cod sursa (job #2577315) | Cod sursa (job #3235660) | Cod sursa (job #91993) | Cod sursa (job #2599902) | Cod sursa (job #2761797)
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int main()
{
int prim = 666013;
vector< vector<int> >hash(prim);
int n;
f >> n;
int op, x;
int cod;
for (int i = 0; i < n; i++) {
f >> op >> x;
cod = x % prim;
if (op == 1) {
hash[cod].push_back(x);
}
if (op == 2) {
for (int j = 0; j < hash[cod].size(); j++) {
if (hash[cod][j] == x)
hash[cod].erase(hash[cod].begin() + j);
}
}
if (op == 3) {
int ok = 0;
for (int j = 0; j < hash[cod].size() && ok != 0; j++) {
if (hash[cod][j] == x) {
ok = 1;
g << ok << endl;
}
}
if (ok == 0) {
g << ok << endl;
}
}
}
}