Cod sursa(job #2760843)

Utilizator Vlad_CalomfirescuVlad calo Vlad_Calomfirescu Data 29 iunie 2021 11:55:08
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.87 kb
////
////  main.cpp
////  hashuri
////
////  Created by Vlad Calomfirescu on 29.06.2021.
////
//
//#include <iostream>
//#include <fstream>
//#include <unordered_set>
//
//using namespace std;
//
//
//
//int main() {
//
//    ifstream fin("hashuri.in");
//    ofstream fout("hashuri.out");
//
//    fin.sync_with_stdio(false);  //aparent functioneaza la optimizare,                                  fara 70p
//    fin.tie(0);
//
//    unordered_set<int> hashh;
//
//    int n,op,a;
//    fin>>n;
//    for (int i=0; i<n; i++)
//    {
//        fin>>op>>a;
//        if(op==1)
//        {
//            hashh.insert(a);
//            continue;
//        }
//      if (op==2)
//        {
//            hashh.erase(a);
//            continue;
//        }
//       // else
//        //{
//            fout<< (hashh.find(a) != hashh.end())<<'\n';
//       // }
//
////        fin>>op;
////        switch(op){
////            case 1:
////                fin>>x;
////                hashh.insert(x);
////                continue;
////            case 2:
////                fin>>x;
////                hashh.erase(x);
////                continue;
////            case 3:
////                fin>>x;
////                if(hashh.find(x) != hashh.end())
////                    fout<<1<<endl;
////                else
////                    fout<<0<<endl;
////        }
//    }
//
//    return 0;
//}
//
//
//
//


#include <fstream>
#include <unordered_set>
 
using namespace std;
 
 
int main()
{
 
  ifstream fin("hashuri.in");
  ofstream fout("hashuri.out");
 
  fin.sync_with_stdio(false);
  fin.tie(0);
  
 
  unordered_set<int> Hash;
  int N, op, x;
  fin >> N;
  for (int i = 0; i < N; ++i) {
    fin >> op >> x;
    if (op == 1) {
      Hash.insert(x);
      continue;
    }
    if (op == 2) {
      Hash.erase(x);
      continue;
    }
    fout << (Hash.find(x) != Hash.end()) << "\n";
  }
  
  return 0;
}