Cod sursa(job #1502148)

Utilizator eu3neuomManghiuc Teodor-Florin eu3neuom Data 14 octombrie 2015 11:37:04
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.73 kb
#include <bits/stdc++.h>

using namespace std;

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

unordered_map < int, int > Map;

int main(){
    int n, type, x;
    fin >> n;
    unordered_map < int, int > ::const_iterator res;
    for(int i = 1; i <= n; i++){
        fin >> type >> x;
        if(type == 1){
            Map.insert(make_pair(x, 0));
        }
        if(type == 2){
            res = Map.find(x);
            if(res != Map.end()) Map.erase(Map.find(x));
        }
        if(type == 3){
            res = Map.find(x);
            if(res == Map.end()){
                fout << 0 << "\n";
            } else {
                fout << 1 << "\n";
            }
        }
    }
    return 0;
}