Cod sursa(job #711874)

Utilizator dacyanMujdar Dacian dacyan Data 12 martie 2012 20:46:45
Problema Hashuri Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.57 kb
#include <fstream>
#include <map>
#include <vector>
using namespace std;

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

map<int, int> M;
int n, tip, x, nr;


int main()
{
    fin >> n;
    for (int i = 1; i <= n; ++i)
    {
        fin >> tip >> x;
        if (tip == 1 && M.find(x) == M.end()) M[x] == ++nr;
        if (tip == 2 && M.find(x) == M.end()) M.erase(x);
        if (tip == 3)
                if (M.find(x) == M.end()) fout << "0\n";
                else fout << "1\n";
    }
    fin.close();
    fout.close();
    return 0;
}