Cod sursa(job #1819896)

Utilizator vladm98Munteanu Vlad vladm98 Data 30 noiembrie 2016 22:38:11
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.93 kb
#include <bits/stdc++.h>

using namespace std;
map <int, int> v;
int readInt()
{
    int raspuns = 0;
    char c;
    while(true)
    {
        c = getchar_unlocked();
        if (c >= '0' && c<='9')
            break;
    }
    raspuns = c-'0';
    while (true)
    {
        c = getchar_unlocked();
        if (c<'0' || c>'9')
            return raspuns;
        raspuns = 10*raspuns + (c-'0');
    }
}
int main()
{
    freopen ("hashuri.in", "r", stdin);
    freopen ("hashuri.out", "w", stdout);
    int n, x, op, i;
    n = readInt();
    for (i = 0; i<n; ++i)
    {
        op = readInt();
        x = readInt();
        if (op == 1 && v.count(x) == 0)
            v[x] = 1;
        if (op == 2 && v.count(x) == 1)
            v.erase (x);
        if (op == 3)
        {
            if (v.count(x))
                fout << 1 << '\n';
            else fout << 0 << '\n';
        }
    }
    return 0;
}