Cod sursa(job #1756630)

Utilizator dtoniucDaniel Toniuc dtoniuc Data 13 septembrie 2016 11:12:11
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.68 kb
#include <fstream>
#include <map>

using namespace std;

int main()
{
    ifstream fin;
    ofstream fout;
    fout.open("hashuri.out");
    fin.open("hashuri.in");

    int n, tip, x;
    map<int, bool> hashMap;

    fin >> n;
    for(int i = 1; i <= n; i++)
    {
    	fin >> tip >> x;
    	switch(tip)
    	{
    		case 1 :
    			if(hashMap.find(x) == hashMap.end())
    				hashMap[x] = true;
    			break;
    		case 2 :
    			hashMap.erase(x);
    			break;
    		case 3 :
    			if(hashMap.find(x) != hashMap.end())
    				fout << "1\n";
    			else
    				fout << "0\n";
    			break;
    		default :
    			exit(1);
    	}
    }

    fin.close();
    fout.close();
    return 0;
}