Cod sursa(job #1528975)

Utilizator alexandru.ghergutAlexandru-Gabriel Ghergut alexandru.ghergut Data 20 noiembrie 2015 12:32:12
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>
#include <unordered_set>
using namespace std;

int main()
{
    int N, x, op, i;
    unordered_set<int> h;
    ifstream f("hashuri.in");
    ofstream g("hashuri.out");

    f >> N;
    for (i = 0; i < N; i++)
    {
        f >> op;
        f >> x;
        switch(op)
        {
        case 1:
            h.insert(x);
            break;
        case 2:
            h.erase(x);
            break;
        case 3:
            if (h.find(x) != h.end())
                g << 1;
            else
                g << 0;
            g << '\n';
            break;
        }
    }

    f.close();
    g.close();
    return 0;
}