Cod sursa(job #580139)

Utilizator LgregL Greg Lgreg Data 12 aprilie 2011 19:33:22
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.64 kb
#include<stdio.h>
#include<algorithm>
#include<set>
#define MOD 35000
using namespace std;
int N,x,y;
set<int> g[MOD];
int hash(int x)
{
    return x%MOD;
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
    scanf("%d",&N);
    for(int i=1;i<=N;++i)
    {
        scanf("%d%d",&x,&y);
        if(x==1)
        {
            g[hash(y)].insert(y);
        }
        if(x==2)
        {
            g[hash(y)].erase(y);
        }
        if(x==3)
        {
            if(g[hash(y)].find(y)!=g[hash(y)].end())
                printf("1\n");
                else printf("0\n");
        }
    }
}