Pagini recente » Cod sursa (job #2316723) | Cod sursa (job #2937322) | Cod sursa (job #537357) | Cod sursa (job #535116) | Cod sursa (job #3130137)
#include <iostream>
#include <fstream>
#include <queue>
#include <algorithm>
int n, tipOp, x;
//std::ifstream fin("C:\\Users\\DelMX\\OneDrive\\Sharing\\tema-sd-3\\hashuri.in");
//std::ofstream fout("C:\\Users\\DelMX\\OneDrive\\Sharing\\tema-sd-3\\hashuri.out");
std::ifstream fin("hashuri.in");
std::ofstream fout("hashuri.out");
int bigN = 666666;
std::vector<int> v[666666];
bool cautare(int x) {
int cheie = x % bigN;
for (int i = 0; i < v[cheie].size(); ++i) {
if (v[cheie][i] == x)
return 1;
}
return 0;
}
int main() {
fin >> n;
for (int i = 0; i < n; ++i) {
fin >> tipOp >> x;
int cheie = x % bigN;
switch(tipOp) {
case 1: {
if (!cautare(x)); {
v[cheie].push_back(x);
}
break;
}
case 2: {
for (int i = 0; i < v[cheie].size(); ++i) {
if (v[cheie][i] == x) {
for (int j = i; j < v[cheie].size(); ++j) {
v[cheie][j] = v[cheie][j + 1];
}
v[cheie].pop_back();
}
}
break;
}
case 3: {
// std::cout << cautare(x) << "\n";
fout << cautare(x) << "\n";
break;
}
}
}
return 0;
}