Cod sursa(job #1135962)

Utilizator sddddgjdZloteanu Anastasia sddddgjd Data 8 martie 2014 16:58:58
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.65 kb
#include <algorithm>
#include <stdio.h>
#include <unordered_set>
using namespace std;
struct hash
{
    inline size_t operator()(int val) const
    {
        return (val & ((1 << 20) - 1));
    }
};
unordered_set<int, hash> h;
int main()
{
    FILE *fin,*fout;
    fin=fopen("hashuri.in","r");
    fout=fopen("hashuri.out","w");
    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;
}