Cod sursa(job #3246313)

Utilizator StefanP03Poleac Liviu Stefan StefanP03 Data 2 octombrie 2024 18:43:46
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.79 kb
#include <iostream>
#include <fstream>
#include <unordered_set>


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

std::unordered_set<int> hashSet;

int existsElement(int x){

    if(hashSet.find(x) != hashSet.end())
    {
        return 1;
    }

    return 0;

}

void deleteElement(int x){
    hashSet.erase(x);
}

void insertElement(int x){
    hashSet.insert(x);
}

int main()
{
    int n;
    in>>n;
    for(int i=0;i<n;i++)
    {
        int op,x;
        in>>op>>x;
        if(op==1)
            {
                insertElement(x);
            }
        else if(op==2)
        {
            deleteElement(x);
        }
        else if(op==3)
        {
            out<<existsElement(x)<<'\n';
        }
    }





    return 0;
}