Pagini recente » Cod sursa (job #1436351) | Cod sursa (job #2197409) | Cod sursa (job #253134) | Cod sursa (job #2197224) | Cod sursa (job #1747588)
#include <iostream>
#include <fstream>
#include <vector>
#define Max 1000000
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
vector<int> rest[Max];
int main() {
int n, i, j, v, operatie, valoare, poz;
bool ok;
fin >> n;
for (i = 0; i < n; i++) {
fin >> operatie >> valoare;
v = valoare % Max;
if (operatie == 1) {
ok = false;
for (j = 0; j < rest[v].size(); j++) {
if (rest[v][j] == valoare) {
ok = true;
}
}
if (valoare) {
rest[v].push_back(valoare);
}
continue;
}
if (operatie == 2) {
poz = -1;
for (j = 0; j < rest[v].size(); j++) {
if (rest[v][j] == valoare) {
poz = j;
}
}
if (poz >= 0) {
swap(rest[v][poz], rest[v][rest[v].size() - 1]);
rest[v].pop_back();
}
continue;
}
poz = -1;
for (j = 0; j < rest[v].size(); j++){
if (rest[v][j] == valoare) {
poz = j;
}
}
if (poz >= 0) {
fout << 1 << "\n";
}
else {
fout << 0 << "\n";
}
}
return 0;
}