Cod sursa(job #1519889)

Utilizator alittlezzCazaciuc Valentin alittlezz Data 7 noiembrie 2015 23:37:10
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.8 kb
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;

//const int m = 1e9+7;
//const double e = 1e-8;

//long long lgPow(long long a, long long b);
//int binarySearch(int x, int n);
//void sieve(int n);
//inline int gcd(int a, int b);

//const int N = 100;
//int st[N+5], dr[50], sp[50];
//bool ciur[N+5];
//int a[N+5];
//int d[N+5];
//int v[N+5];
//char m[N+5][N+5];
//vector < pair <string, int> > v;
//map <int, int> m;
//bool a[26];
//char s[N+5];
//string s;
unordered_set <int> m;

int main()
{
    int x,op,n,i;
    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){
            m.insert(x);
        }else if(op == 2){
            m.erase(x);
        }else{
            printf("%d\n",m.find(x) != m.end());
        }
    }
    return 0;
}

//long long lgPow(long long a, long long b){
//    long long sol = 1;
//    while(b){
//        if(b&1){
//            sol = sol*a;
//        }
//        a = a*a;
//        b >>= 1;
//    }
//    return sol;
//}

//int binarySearch(int x, int n){
//    int step,i;
//    for(step = 1;step <= n;step <<= 1);
//    for(i = 0;step;step >>= 1){
//        if(i + step <= n && v[i+step] <= x){
//            i += step;
//        }
//    }
//    if(v[i] == x){
//        return i;
//    }
//    return -1;
//}

//void sieve(int n){
//    int i,j;
//    for(i = 4;i <= n;i += 2){
//        ciur[i] = 1;
//    }
//    for(i = 3;i <= n;i += 2){
//        if(!ciur[i]){
//            for(j = 3*i;j <= n;j += i+i){
//                ciur[j] = 1;
//            }
//        }
//    }
//}

//inline int gcd(int a, int b){
//    if(b == 0) return a;
//    return gcd(b,a%b);
//}