Cod sursa(job #2075094)

Utilizator sebi_andrei2008Lazar Eusebiu sebi_andrei2008 Data 25 noiembrie 2017 11:22:11
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
#include <iostream>
#include <hash_map>
#include <fstream>
using namespace std;
using namespace __gnu_cxx;

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

int n, op, x;

int main()
{
    hash_map<int, bool> hashTable;
    fin>>n;
    while (n) {
        fin>>op>>x;
        switch (op) {
            case 1:
              //  hashTable[x] =1;
                hashTable.insert({x, 1});
                break;
            case 2:
             //   hashTable[x] = 0;
                if (hashTable.count(x))
                    hashTable.erase(x);
                break;
            case 3:
                if (hashTable.count(x))
                    fout<<1<<"\n";
                else
                    fout<<0<<"\n";
                break;
        }
        n--;
    }
    return 0;
}