Cod sursa(job #2653476)

Utilizator Razvan48Capatina Razvan Nicolae Razvan48 Data 28 septembrie 2020 10:57:02
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.92 kb
#include <fstream>
#include <unordered_set>

using namespace std;

unordered_set<int> hm;

int main()
{
    ifstream in("hashuri.in");
    ofstream out("hashuri.out");
    int n, op, x;

    in >> n;
    for (int i = 1; i <= n; i++)
    {
        in >> op >> x;

        if (op == 1)
        {
            if (hm.find(x) == hm.end())
            {
                hm.emplace(x);
            }
        }
        else
        {
            if (op == 2)
            {
                if (hm.find(x) != hm.end())
                {
                    hm.erase(hm.find(x));
                }
            }
            else
            {
                if (hm.find(x) == hm.end())
                {
                    out << 0 << '\n';
                }
                else
                {
                    out << 1 << '\n';
                }
            }
        }
    }

    return 0;
}