Cod sursa(job #1685141)

Utilizator gabib97Gabriel Boroghina gabib97 Data 11 aprilie 2016 15:37:33
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <stdio.h>
#include <vector>
#include <unordered_map>
#define w 200017
using namespace std;
int n,i,op,x,r;
unordered_map<int,bool> H;

int find(int x)
{
    return H.count(x);
}
void insert(int x)
{
    if (!find(x)) H[x]=1;
}
void remove(int x)
{
    if (find(x)) H.erase(x);
}

int main()
{
    freopen ("hashuri.in","r",stdin);
    freopen ("hashuri.out","w",stdout);
    scanf("%i",&n);
    while (n--)
    {
        scanf("%i%i",&op,&x);
        r=x%w;
        switch (op)
        {
        case 1:
            insert(x);
            break;

        case 2:
            remove(x);
            break;
        case 3:
            printf("%i\n",find(x));
            break;
        }
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}