Cod sursa(job #1533314)

Utilizator rzvrzvNicolescu Razvan rzvrzv Data 22 noiembrie 2015 13:22:22
Problema Hashuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
#include<cstdio>
#include<vector>

using namespace std;

vector<int> h[666013];
int i,n,op,x,pos;

int gaseste(int x)
{
    int it;
    for(it=0;it<h[x%666013].size();it++)
    {
        if(h[x%666013][it]==x)
        {
            return it+1;
        }
    }
    return 0;
}

int main()
{
    freopen("hashuri.in","r",stdin);
    freopen("hashuri.out","w",stdout);
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&op,&x);
        if(op==1)
        {
            if(!gaseste(x))
            {
                h[x%666013].push_back(x);
            }
        }
        if(op==2)
        {
            pos=gaseste(x)-1;
            h[x%666013].erase(h[x%666013].begin()+pos);
        }
        if(op==3)
        {
            printf("%d\n",(gaseste(x)>0));
        }
    }
}