Cod sursa(job #2773550)

Utilizator iustin.pericicaPericica Iustin iustin.pericica Data 7 septembrie 2021 16:18:23
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <iostream>
#include <fstream>
#include <unordered_set>

using namespace std;

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

unordered_set<int> hashSet;

int main()
{
    int n;
    int operatie, x;
    fin>>n;
    for(int i = 1;i<=n;++i){
        fin>>operatie>>x;
        if(operatie == 1){
            hashSet.insert(x);
        }
        else if(operatie == 2){
            hashSet.erase(x);
        }
        else{
            if(hashSet.find(x) == hashSet.end()){
                fout<<0<<"\n";
            }
            else fout<<1<<"\n";
        }
    }
    return 0;
}