Cod sursa(job #2908452)

Utilizator andrei_srbnSerban Andrei andrei_srbn Data 3 iunie 2022 16:36:17
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.83 kb
#include <iostream>
#include <unordered_map>
#include <fstream>

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

unordered_map <int,int> my_map;



int main()
{
    int n;
    int op,x;
    fin>>n;
    for(int i=1;i <= n; i++)
    {
        fin >> op >> x;
        if(op == 1)
        {
            if(my_map.find(x) == my_map.end())   ///daca x nu se afla in map
            {
                my_map[x] = 1;
            }

        }
        else if(op == 2)
        {
            if(my_map.find(x) != my_map.end())
            {
                my_map.erase(x);
            }

        }
        else
        {
            if(my_map.find(x) != my_map.end())
                fout<<1<<"\n";
            else
                fout<<0<<"\n";

        }
    }

    return 0;
}