Cod sursa(job #1001792)

Utilizator PlatonPlaton Vlad Platon Data 26 septembrie 2013 08:17:04
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.68 kb
#include <iostream>
#include <fstream>
#include <map>

using namespace std;

int n;

map<int, int> m;

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

int main(int argc, char** argv)
{
    int op = 3;
    int x;

    f>>n;

    for(int i=0;i<n;i++)
    {
        f>>op;
        f>>x;

        cout<<op<<endl<<x;

        switch(op)
        {
            case 1:
                if(m.find(x)==m.end()) m[x]=1;
                break;
            case 2:
                m.erase(x);
                break;
            case 3:
                g<<m[x]<<"\n";
                break;
        }
    }

    f.close();
    g.close();

    return 0;
}