Cod sursa(job #2975250)

Utilizator vladburacBurac Vlad vladburac Data 5 februarie 2023 21:59:24
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.67 kb
#include <bits/stdc++.h>
using namespace std;

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

unordered_map <int, int> elements;
int main() {
  int n, op, x;
  fin >> n;
  while( n-- ) {
    fin >> op >> x;
    if( op == 1 ) {
      auto it = elements.find( x );
      if( it == elements.end() )
        elements.insert( { x, 1 } );
    }
    else if( op == 2 ) {
      auto it = elements.find( x );
      if( it != elements.end() )
        elements.erase( x );
    }
    else {
      auto it = elements.find( x );
      if( it != elements.end() )
        fout << 1 << "\n";
      else
        fout << 0 << "\n";
    }
  }
  return 0;
}