Cod sursa(job #580149)

Utilizator LgregL Greg Lgreg Data 12 aprilie 2011 19:37:35
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include<fstream>
#include<algorithm>
#include<set>
#define MOD 33500

using namespace std;
int N,x,y;
set<int> g[MOD];
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int hash(int x)
{
    return x%MOD;
}
int main()
{
fin>>N;
    for(int i=1;i<=N;++i)
    {
        fin>>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())
                fout<<"1\n";
                else fout <<"0\n";
        }
    }
}