Cod sursa(job #2625039)

Utilizator CoakazeRotaru Catalin Coakaze Data 5 iunie 2020 18:02:42
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;

unordered_map <int, int> m;

int main()
{
    ifstream f("hashuri.in");
    ofstream g("hashuri.out");
    int n, nr;
    int i, tip, x;
    f>>n;
    for (i=1; i<=n; ++i)
    {
        f>>tip>>x;
        if (tip == 1)
            m.insert({x, 1});
        if (tip == 2)
            {
                if(m.find(x) != m.end())
                    m.erase(x);
            }
        if (tip == 3)
        {
            if (m.find(x) != m.end())
                g<<1<<"\n";
            else
                g<<0<<"\n";
        }
    }
    return 0;
}