Cod sursa(job #2036833)

Utilizator MarutBrabete Marius Stelian Marut Data 11 octombrie 2017 09:42:36
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.71 kb
//#include<bits/stdc++.h>
#include <cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
const int m=666013;
int h (int key)
{
    return key%m;
}
set<int>v[m+5];
int main()
{
    freopen("hashuri.in","r",stdin);
    freopen("hashuri.out","w",stdout);
    int n,i,j,tip,k,x,help;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&tip,&x);
        help=h(x);
        if(tip==1) v[help].insert(x);
            else if(tip==2) v[help].erase(x);
                else
                {
                    if(v[help].find(x)!=v[help].end()) printf("1\n");
                        else printf("0\n");
                }
    }
    return 0;
}