Cod sursa(job #1152863)

Utilizator Dragan_ValentinDragan Valentin Dragan_Valentin Data 25 martie 2014 00:29:01
Problema Hashuri Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.7 kb
#include <iostream>
#include <cstdio>
#include <fstream>
#include <set>
#include <vector>
#define div 666013

using namespace std;

set <int> h[666013];

void add_hash(int x)
{
    h[x%div].insert(x);
}

void remove_hash(int x)
{
    h[x%div].erase(x);
}

short search_hash(int x)
{
    if (h[x%div].find(x) != h[x%div].end()) return 1;
    return 0;
}


int main()
{
    int n,i;
    int op,x;
    freopen("hashuri.in","r",stdin);
    ofstream g("hashuri.out");
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        scanf("%d %d",&op,&x);
        if (op==1) add_hash(x);
        else if (op==2) remove_hash(x);
        else g<<search_hash(x)<<'\n';
    }
    return 0;
}