Cod sursa(job #3212613)

Utilizator QwertyDvorakQwerty Dvorak QwertyDvorak Data 11 martie 2024 23:15:03
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.56 kb
#include <bits/stdc++.h>
using namespace std;

const string FILENAME = "hashuri";

ifstream fin(FILENAME + ".in");
ofstream fout(FILENAME + ".out");

int n;
unordered_map<int, bool> m;
int main()
{
    int op, x;
    fin >> n;
    while (n--)
    {
        fin >> op >> x;
        if (op == 1)
            m[x] = true;
        else if (op == 2)
        {
            if (m.find(x) != m.end())
                m.erase(m.find(x));
        }
        else
            fout << ((m.find(x) != m.end()) ? "1\n" : "0\n");
    }
    fin.close();
    fout.close();
    return 0;
}