Cod sursa(job #3152668)

Utilizator SSKMFSS KMF SSKMF Data 26 septembrie 2023 10:36:33
Problema Balanta Scor 60
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.84 kb
#include <fstream>
using namespace std;

ifstream cin ("balanta.in");
ofstream cout ("balanta.out");

bool eliminat[1025];

int main ()
{
    int numar_monede , incercari;
    cin >> numar_monede >> incercari;

    int ramas = numar_monede;
    for (int eliminare = 1 ; eliminare <= incercari && ramas > 1 ; eliminare++)
    {
        int lungime;
        cin >> lungime;

        int multime[1025];
        for (int indice = 1 ; indice <= numar_monede ; indice++)
            multime[indice] = 0;

        for (int indice_1 = 1 , valoare ; indice_1 <= 2 ; indice_1++)
            for (int indice_2 = 1 ; indice_2 <= lungime ; indice_2++)
                { cin >> valoare; multime[valoare] = indice_1; }

        int sens;
        cin >> sens;

        switch (sens)
        {
            case 0:
                for (int indice = 1 ; indice <= numar_monede ; indice++)
                    if (multime[indice] && !eliminat[indice]) 
                        { eliminat[indice] = true; ramas--; }
            break;

            case 1:
                for (int indice = 1 ; indice <= numar_monede ; indice++)
                    if (multime[indice] != 1 && !eliminat[indice])
                        { eliminat[indice] = true; ramas--; }
            break;
        
            case 2:
                for (int indice = 1 ; indice <= numar_monede ; indice++)
                    if (multime[indice] != 2 && !eliminat[indice])
                        { eliminat[indice] = true; ramas--; }
            break;
        }
    }

    if (ramas != 1)
        cout << '0';
    else
    {
        int falsificat = 0;
        for (int indice = 1 ;!falsificat ; indice++)
            if (!eliminat[indice])
                falsificat = indice;

        cout << falsificat;
    }

    cout.close(); cin.close();
    return 0;
}