Cod sursa(job #2892925)

Utilizator DariaClemClem Daria DariaClem Data 23 aprilie 2022 23:38:49
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 kb
#include <bits/stdc++.h>

using namespace std;

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

unordered_map<int, int> elemente;

int main() {
    int nrOperatii, index, operatie, numar, aparitii;
    fin >> nrOperatii;
    for (index = 0; index < nrOperatii; index += 1) {
        fin >> operatie >> numar;
        aparitii = elemente.count(numar);
        if (operatie == 1) {
            if(aparitii == 0){
                elemente[numar] = 1;
            }
        }
        if (operatie == 2) {
            if(aparitii){
                elemente.erase(numar);
            }
        }
        if (operatie == 3) {
            fout<<(aparitii > 0 ? 1 : 0)<<"\n";
        }
    }
    return 0;
}