Cod sursa(job #3121240)

Utilizator danutbodbodnariuc danut danutbod Data 11 aprilie 2023 11:46:39
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.09 kb
#include <bits/stdc++.h>  //80p cu map - timp depasit
// 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;
}
//var I
//#include <cstdio>//80p  cu set - timp depasit
//#include <set>
//using namespace std;
//int n,op,x,i;
//set<int> A; //arbore echilibrat binar operatii O(log(n))-insert, erase,find
//
//int main()
//{
//    freopen("hashuri.in", "r", stdin);
//    freopen("hashuri.out", "w", stdout);
//    scanf("%d", &n);
//    for(i=1;i<=n;i++)
//    {
//        scanf("%d %d", &op, &x);
//        if (op == 1)
//        {   A.insert(x); continue; }
//        if (op == 2)
//        {   A.erase(x);  continue; }
//        printf("%d\n", A.find(x) != A.end());
//    }
//   return 0;
//}