Cod sursa(job #2623724)

Utilizator anacomoAna-Maria Comorasu anacomo Data 3 iunie 2020 17:13:33
Problema Hashuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.96 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

unordered_map<int, bool> hashmap;
int main()
{
    int choice, n;
    int element;
    fin >> n;
    for (unsigned i = 0; i < n; ++i)
    {
        fin >> choice;
        switch (choice)
        {
        case 1:
            fin >> element;
            //hashmap[element] = true;
            hashmap.insert(make_pair(element, true));
            break;
        case 2:
            fin >> element;
            //hashmap[element] = false;
            auto it = hashmap.find(element);
            if(it != hashmap.end())
                hashmap.erase(element);
            break;
        case 3:
            fin >> element;
            auto it = hashmap.find(element);
            if(it != hashmap.end())
                fout << "1" << '\n';
            else
                fout << "0" << '\n';
            break;
        default:
            break;
        }
    }
    return 0;
}