Cod sursa(job #2625965)

Utilizator sorinnsgNeculae Andrei-Sorin sorinnsg Data 6 iunie 2020 11:12:25
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.88 kb
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");

int main()
{
    int a, b, n;
    f >> n;

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