Cod sursa(job #2626020)

Utilizator sorinnsgNeculae Andrei-Sorin sorinnsg Data 6 iunie 2020 11:27:42
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.84 kb
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");

unordered_map<int,int> hashmap;
unordered_map<int,int>::iterator x;
int main()
{
    int a, b, n;
    f >> n;

    for (unsigned i = 0; i < n; ++i)
    {
        f >> a>>b;
        switch (a)
        {
        case 1:
            hashmap.insert(make_pair(b, 1));
            break;
        case 2:
            x=hashmap.find(b);
            if (x != hashmap.end())
                hashmap.erase(b);
            break;
        case 3:
            x=hashmap.find(b);
            if (x != hashmap.end())
                g << 1 << endl;
            else
                g << 0 << endl;
            break;
        default:
            break;
        }
    }
    f.close();
    g.close();
    return 0;
}