Cod sursa(job #1604607)

Utilizator tudormaximTudor Maxim tudormaxim Data 18 februarie 2016 13:50:11
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.58 kb
#include <iostream>
#include <fstream>
#include <map>
using namespace std;

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

map <int,int> h;
int n, nr;

int main()
{
    ios_base::sync_with_stdio(false);
    int i, op, x;
    fin >> n;
    for(i=1; i<=n; i++)
    {
        fin >> op >> x;
        if(op==1 && h.find(x)==h.end()) h[x] = ++nr;
        if(op==2) h.erase(x);
        if(op==3)
        {
            if(h.find(x)!=h.end()) fout << "1\n";
            else fout << "0\n";
        }
    }
    fin.close();
    fout.close();
    return 0;
}