Cod sursa(job #1494817)

Utilizator gabi.cristacheGabi Cristache gabi.cristache Data 1 octombrie 2015 21:27:24
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.7 kb
#include <fstream>
#include <unordered_map>

using namespace std;

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

int main()
{
    unordered_map<int, bool> myhash;
    int N, op, x;
    fin >> N;
    for (int i = 1; i <= N; ++i) {
        fin >> op >> x;
        if (op == 1) {
            if (myhash.find(x) == myhash.end()) {
                myhash[x] = true;
            }
        } else if (op == 2) {
            unordered_map<int, bool>::iterator it = myhash.find(x);
            if (it != myhash.end()) {
                myhash.erase(it);
            }
        } else {
            fout << (myhash.find(x) != myhash.end()) << '\n';
        }
    }

    return 0;
}