Cod sursa(job #3131133)

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

int caut(map <int, int> hash, int nr){
    if(hash.count(nr) == 1)
        return 1;
    return 0;
}

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

            case 2: sterg(hash, b);
            break;

            case 3: fout<<caut(hash, b)<<"\n";
            break;
        }
    }

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