Cod sursa(job #1580051)

Utilizator alittlezzCazaciuc Valentin alittlezz Data 25 ianuarie 2016 13:55:35
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <bits/stdc++.h>

using namespace std;

set <int> s;

int main()
{
    int op,n,i,x;
    freopen("hashuri.in", "r", stdin);
    freopen("hashuri.out", "w", stdout);
    scanf("%d",&n);
    for(i = 1;i <= n;i++){
        scanf("%d %d",&op,&x);
        if(op == 1){
            if(s.find(x) == s.end()){
                s.insert(x);
            }
        }else if(op == 2){
            if(s.find(x) != s.end()){
                s.erase(x);
            }
        }else{
            if(s.find(x) != s.end()){
                printf("1\n");
            }else{
                printf("0\n");
            }
        }
    }
    return 0;
}