Cod sursa(job #2282567)

Utilizator skoda888Alexandru Robert skoda888 Data 14 noiembrie 2018 08:52:22
Problema Hashuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.84 kb

#include <iostream>
#include <fstream>
#include <unordered_map>

int main()
{
    std::ifstream in("hashuri.in");
    std::ofstream out("hashuri.out");

    int num_op;
    in >> num_op;

    std::unordered_map<long long, long long> Hash;
    int operatie;
    int index = 0;
    int x;
    while(in >> operatie){
        switch(operatie){
        case 1:
            in >> x;
            if(Hash.find(x) == Hash.end()){
                Hash[x] = ++index;
            }
            break;
        case 2:
            in >> x;
            Hash.erase(x);
            break;
        default:
            in >> x;
            if(Hash.find(x) != Hash.end()){
                out << 1 << ' ';
            }
            else{
                out << 0 << ' ' ;
            }
            break;
        }

    }
    return 0;
}