Cod sursa(job #654038)

Utilizator titeltitel popescu titel Data 29 decembrie 2011 13:46:24
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
// Abordarea directa a problemei are complexitatea O(N2) si obtine 30 de puncte.
#include <fstream>
#include <set>
#define NMax 1000005
using namespace std;
ifstream f("hashuri.in"); ofstream g("hashuri.out");
int N;
set<int> A;
int main()
{   int op, x;
	f>>N;
    for (; N; --N)
    { 	f>>op>>x;
        if (op == 1) {A.insert(x); continue;}        
        if (op == 2) {A.erase(x); continue;}
		if (A.find(x) == A.end()) g<<"0\n"; else g<<"1\n";
    }
    g.close(); return 0;
}