Pagini recente » Cod sursa (job #1908710) | Cod sursa (job #1141449) | Cod sursa (job #1325719) | Cod sursa (job #2091164) | Cod sursa (job #2733835)
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
#define PRIM 10000
// ifstream fin("input.txt");
// ofstream fout("output.txt");
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector<int> Hash[PRIM];
int operatie_3 (int x) {
int indice = x % PRIM;
for (unsigned int i = 0; i < Hash[indice].size(); i++) {
if (Hash[indice][i] == x)
return 1;
}
return 0;
}
void operatie_1 (int x) {
int indice = x % PRIM;
if (operatie_3(x) == 0)
Hash[indice].push_back(x);
}
void operatie_2 (int x) {
int indice = x % PRIM;
int contor = 0, pozitie;
for (unsigned int i = 0; i < Hash[indice].size(); i++) {
if (Hash[indice][i] == x) {
contor = 1;
pozitie = i;
}
}
if (contor == 1) {
Hash[indice].erase(Hash[indice].begin() + pozitie);
}
}
int main() {
int n, opcode, nr;
fin >> n;
for (int i = 0; i < n; i ++) {
fin >> opcode >> nr;
if (opcode == 1) {
operatie_1(nr);
}
if (opcode == 2) {
operatie_2(nr);
}
if (opcode == 3) {
fout << operatie_3(nr) << '\n';
}
}
return 0;
}