Cod sursa(job #2472453)

Utilizator MaionezaMaioneza Maioneza Maioneza Data 12 octombrie 2019 13:29:26
Problema Hashuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.9 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream in ("hashuri.in");
ofstream out ("hashuri.out");

#define M 666013

int v[M][100];

int main()
{
    int n, i, p, x, ok, j;
    in >> n;
    for (i=0; i<n; i++)
    {
        in >> p >> x;
        if (p==1)
        {
            ok=0;
            for (j=0; j<v[x%M][0] && ok==0; j++) if (v[x%M][j]==x) ok=1;
            if (ok==0)
            {
                v[x%M][v[x%M][0]]=x;
                v[x%M][0]++;
            }
        }

        else if (p==2)
        {
            for (j=0; j<v[x%M][0]; j++) if (v[x%M][j]==x) {for (int k=j; k<v[x%M][0]-1; k++) v[x%M][k]=v[x%M][k+1]; v[x%M][0]--;}
        }

        else if (p==3)
        {
            ok=0;
            for (j=0; j<v[x%M][0]; j++) if (v[x%M][j]==x) {ok=1; out << 1;}
            if (ok==0) out << 0;
        }
    }

    return 0;
}