Cod sursa(job #3129012)

Utilizator AlexC23Codreanu Alex-Cosmin AlexC23 Data 12 mai 2023 00:51:39
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.68 kb
#include <iostream>
#include <unordered_map>
#include <fstream>
using namespace std;

int main()
{
    ifstream f("hashuri.in");
    ofstream g("hashuri.out");
    int n, a, b;
    unordered_map<int,int>hashtabel;
    f>>n;
    for(int i=0;i<n;i++)
    {
        f>>a>>b;
        if (a==1 and hashtabel.count(b)==0)
        {
            hashtabel[b]=1;
        }
        else if(a==2 and hashtabel.count(b)==1)
        {
            hashtabel.erase(b);
        }
        else if(a==3 and hashtabel.count(b)==1)
        {
            g<<1<<endl;
        }
        else if(a==3 and hashtabel.count(b)==0)
        {
            g<<0<<endl;
        }
    }
    f.close();
    g.close();
    return 0;
}