Cod sursa(job #1076313)

Utilizator alexch16Chelariu Alexandru alexch16 Data 10 ianuarie 2014 00:57:08
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.69 kb
//
//  main.cpp
//  Test
//
//  Created by Alexandru Chelariu on 1/10/14.
//  Copyright (c) 2014 Alexandru Chelariu. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <map>

using namespace std;

int main(int argc, const char * argv[])
{
    map<int, int> Map;
    
    ifstream fin("hashuri.in");
    ofstream fout("hashuri.out");
    
    int N, op, el, nr = 0;
    
    fin >> N;
    
    for(int i = 0; i < N; i++){
        fin >> op >> el;
        if(op == 1 && Map.find(el) == Map.end()) {
            Map[el] = ++nr;
        } else if(op == 2) {
            Map.erase(el);
        } else {
            fout << (Map.find(el) != Map.end());
        }
    }
    
    return 0;
}