Cod sursa(job #3121241)

Utilizator danutbodbodnariuc danut danutbod Data 11 aprilie 2023 11:52:27
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.01 kb
#include <bits/stdc++.h>  // cu map
// map //arbore echilibrat binar O(log(n)) - operatiile
using namespace std;
int n,op,x,i,NR;
map <int, int> M;

int main()
{
    ifstream fin("hashuri.in");
    ofstream fout("hashuri.out");
    fin>>n;
    for (i = 1; i <= n; i++)
    {
        fin>>op>>x;
        if (op == 1) M.insert(make_pair(x,1));
        if (op == 2) M.erase(x);
        if (op == 3) fout<<( M.find(x) != M.end())<<'\n';
    }
   fout.close();
    return 0;
}
//#include <bits/stdc++.h>  // cu set
//// set //arbore echilibrat binar O(log(n)) - operatiile
//using namespace std;
//int n,op,x,i,NR;
//set <int> M;
//
//int main()
//{
//    ifstream fin("hashuri.in");
//    ofstream fout("hashuri.out");
//    fin>>n;
//    for (i = 1; i <= n; i++)
//    {
//        fin>>op>>x;
//        if (op == 1 && M.find(x)==M.end()) M.insert(x);
//        if (op == 2) M.erase(x);
//        if (op == 3) fout<<( M.find(x) != M.end())<<'\n';
//    }
//   fout.close();
//    return 0;
//}