Cod sursa(job #773658)

Utilizator paunmatei7FMI Paun Matei paunmatei7 Data 2 august 2012 12:18:43
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.74 kb
#include<cstdio>
#include<vector>
#define mod 666013
using namespace std;
vector <int> v[mod];
vector <int>::iterator it;
int tip,x,n,poz;
int main()
{
    int i;
    freopen("hashuri.in","r",stdin);
    freopen("hashuri.out","w",stdout);
    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d %d",&tip,&x);
        poz=x%mod;
        for (it=v[poz].begin();it!=v[poz].end()&& *it!=x;it++){}
        if (tip==1)
            if (it==v[poz].end())
                v[poz].push_back(x);
        if (tip==2)
            if (it!=v[poz].end())
                v[poz].erase(it);
        if (tip==3)
            if (it!=v[poz].end())
                printf("1\n");
            else
                printf("0\n");
    }
}