Cod sursa(job #951281)

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

using namespace std;

map < string, int > mymap;

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 ){

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

        if ( op == 2 ){

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

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

        if ( op == 3 ){

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

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

    return 0;
}