Cod sursa(job #908223)

Utilizator stef1995mmarcu stefan ovidiu stef1995m Data 8 martie 2013 21:36:02
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int n,mod=666013,i,type,val,poz,m,c;
vector <int> x[666017];
int main()
{
    freopen("hashuri.in","r",stdin);
    freopen("hashuri.out","w",stdout);
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d%lld",&type,&val);
        m=val%mod;
        c=val/mod;
        for(poz=0;poz<x[m].size() && x[m][poz]!=c ;poz++);
        if(type==1)
            x[m].insert(x[m].begin()+poz,c);
        else
            if(type==2)
            {
                if(poz<x[m].size())
                    x[m].erase(x[m].begin()+poz);
            }
            else
                if(poz>=x[m].size())
                    printf("0\n");
                else
                    printf("1\n");
    }
    return 0;
}