Cod sursa(job #1049272)

Utilizator arvinte.razvanarvinte razvan arvinte.razvan Data 7 decembrie 2013 10:04:28
Problema Hashuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include <cstdio>
#include <vector>
using namespace std;
vector <int> a[20001];
long n,k,i,x;
int c,rest,ok;
int main()
{
    freopen("hashuri.in","rt",stdin);
    freopen("hashuri.out","wt",stdout);
    scanf("%ld",&n);
    for (k=1;k<=n;k++)
    {
        scanf("%d %ld",&c,&x);
        rest=x%20001;
        if (c==1){
            ok=0;
        for (i=1;i<=a[rest].size();i++)
        if (a[rest][i]==x) ok=1;
        if (ok==0)
        a[rest].push_back(x);
        }
        if (c==2)
        {
        for (i=1;i<=a[rest].size();i++)
        if (a[rest][i-1]==x) a[rest].erase(a[rest].begin()+i-1);
        }
        if (c==3)
        {
        for (i=1;i<=a[rest].size();i++)
        if (a[rest][i-1]==x) ok=1;
        printf("%d\n",ok);
        ok=0;
        }
    }
    return 0;
}