Cod sursa(job #1610945)

Utilizator enacheionutEnache Ionut enacheionut Data 23 februarie 2016 20:46:07
Problema Hashuri Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.7 kb
#include <fstream>
#include <map>

using namespace std;

int main()
{
    int operatie, key, nrOperatii;
    map<int, int> container;

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

    in>>nrOperatii;

    for( int i = 0; i<nrOperatii; ++i )
    {
        in>>operatie>>key;

        if( operatie == 1 && container.find(key) == container.end())
        {
            container.insert(pair<int, int>(key, i));
        }
        else if( operatie == 2 )
        {
            container.erase(key);
        }
        else if( operatie == 3 )
        {
            out<<( container.find(key) != container.end() )<<endl;
        }
    }

    return 0;
}