Cod sursa(job #2885657)

Utilizator Nicolae11Mihaila Nicolae Nicolae11 Data 6 aprilie 2022 12:59:07
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.14 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,op,x,baza,heshu[9973][100];
int main()
{   f>>n;
    baza=9973;
    for(int i=1;i<=n;i++)
    {   f>>op>>x;
        int ok=0;
        int poz=-1;
        if(op==1)
        {   for(int j=1;j<=heshu[x%baza][0];j++)
                if(heshu[x%baza][j]==x)
                    ok=1;
            if(ok!=1)
            {   heshu[x%baza][0]++;
                heshu[x%baza][heshu[x%baza][0]]=x;
            }
        }
        if(op==2)
        {   for(int j=1;j<=heshu[x%baza][0];j++)
                if(heshu[x%baza][j]==x)
                {   ok=1;
                    poz=j;
                }
            if(ok==1)
            {   for(int j=poz;j<heshu[x%baza][0];j++)
                    heshu[x%baza][j]=heshu[x%baza][j+1];
                heshu[x%baza][0]--;
            }
        }
        if(op==3)
        {   for(int j=1;j<=heshu[x%baza][0];j++)
                if(heshu[x%baza][j]==x)
                    ok=1;
            g<<ok<<'\n';
        }
    }
    f.close();
    g.close();
    return 0;
}