Cod sursa(job #2533615)

Utilizator SqueekDanielTodasca Daniel SqueekDaniel Data 29 ianuarie 2020 14:41:53
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.63 kb
#include <bits/stdc++.h>

class HashSet {
public:
    HashSet() {}

    void insert(int value) { set.insert(value); }
    void erase(int value)  { set.erase(value); }
    bool contains(int value) { return set.find(value) != set.end(); }

private:
    std::set <int> set;
};  HashSet set;

std::ifstream input ("hashuri.in");
std::ofstream output("hashuri.out");

int main()
{
    int Q;  input >> Q;
    int op, x;
    while (Q--) {
        input >> op >> x;
        if (op == 1) set.insert(x);
        else if (op == 2) set.erase(x);
        else if (op == 3) output << set.contains(x) << '\n';
    }

    return 0;
}