Cod sursa(job #3131143)

Utilizator Cipy34Harnagea Ciprian Cipy34 Data 19 mai 2023 12:50:42
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.87 kb
#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;
void adaug(unordered_map <int, int> &hash, int nr){
        hash[nr] = 1;
}

void sterg(unordered_map <int, int> &hash, int nr){
        hash.erase(nr);
}
int main()
{
    ifstream fin("hashuri.in");
    ofstream fout("hashuri.out");
    int nr, a, b;
    unordered_map<int, int> hash;
    fin>>nr;
    for(int i = 0; i < nr; i++){
        fin>>a>>b;

        switch(a){
            case 1:
                if(hash.count(b) == 0)
                    adaug(hash, b);
                break;

            case 2:
                if(hash.count(b) == 1)
                    sterg(hash, b);
                break;

            case 3:
                fout<<hash.count(b)<<"\n";
                break;
        }
    }

    fin.close();
    fout.close();
    return 0;
}