Cod sursa(job #951279)

Utilizator AlexandruValeanuAlexandru Valeanu AlexandruValeanu Data 19 mai 2013 22:41:10
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <iostream>
#include <fstream>
#include <map>

using namespace std;

map < string, int > hash;

unsigned int N;

int main(){

    ifstream f( "hashuri.in"  );
    ofstream g( "hashuri.out" );

    f >> N;

    for ( ; N; N-- ){

        unsigned int op;
        string a;

        f >> op >> a;

        if ( op == 1 ){

            hash.insert( pair < string, int > ( a, 1 ) );
        }

        if ( op == 2 ){

            map < string, int > ::iterator it = hash.find( a );

            if ( it != hash.end() )
                hash.erase (it);
        }

        if ( op == 3 ){

            map < string, int > ::iterator it = hash.find( a );

            if ( it != hash.end() )
                g << "1\n";
            else
                g << "0\n";
        }
    }

    return 0;
}