Cod sursa(job #3132066)

Utilizator LazarDanielGabrielLazar Daniel-Gabriel LazarDanielGabriel Data 21 mai 2023 23:01:37
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <iostream>
#include <fstream>
#include <unordered_set>

using namespace std;

ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

int main() {
    int n;
    fin >> n;

    unordered_set<int> hashSet;
    for (int i = 0; i < n; i++) {
        int op, x;
        fin >> op >> x;

        if (op == 1) {
            hashSet.insert(x);
        } else if (op == 2) {
            hashSet.erase(x);
        } else if (op == 3) {
            int result = (hashSet.count(x) > 0) ? 1 : 0;
            fout << result << '\n';
        }
    }

    fin.close();
    fout.close();
    return 0;
}