Cod sursa(job #1135965)

Utilizator sddddgjdZloteanu Anastasia sddddgjd Data 8 martie 2014 17:04:27
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <algorithm>
#include <stdio.h>
#include <unordered_set>
using namespace std;
struct Myhash
{
    inline size_t operator()(int val) const
    {
        return (val & ((1 << 20) - 1));
    }
};
int main()
{
    FILE *fin,*fout;
    fin=fopen("hashuri.in","r");
    fout=fopen("hashuri.out","w");
    unordered_set<int,Myhash> h;
    int n,i;
    fscanf(fin,"%d",&n);
    for(i=0;i<n;i++)
    {
        int tip,val;
        fscanf(fin,"%d%d",&tip,&val);
        if(tip==1)
            h.insert(val);
        if(tip==2)
            h.erase(val);
        if(tip==3)
            fprintf(fout,"%d\n",h.count(val));
    }
    return 0;
}