Cod sursa(job #1696927)

Utilizator sucureiSucureiRobert sucurei Data 30 aprilie 2016 12:54:05
Problema Bowling Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.32 kb
#include <cstring>
#include <fstream>
#include <algorithm>

using namespace std;

int T, N;
int SP[1002];
bool ok[1002];

int main()
{
    ifstream fin("bowling.in");
    ofstream fout("bowling.out");

    // ciclic din 12 in 12 (de la un moment dat)

    for (int i = 1; i <= 1000; ++i)
    {
        memset(ok, 0, sizeof(ok));
        for (int j = 0; j <= i - 1; ++j)
            ok[SP[j] ^ SP[i - j - 1]] = true;
        for (int j = 0; j <= i - 2; ++j)
            ok[SP[j] ^ SP[i - j - 2]] = true;
        for (int j = 0; ok[j]; ++j, ++SP[i]);
    }

    fin >> T;
    for (int test = 1; test <= T; ++test)
    {
        fin >> N;

        int now = 0, result = 0;
        for (int i = 1, aux; i <= N; ++i)
        {
            fin >> aux;
            if (aux == 0)
            {
                if (now != 0)
                {
                    if (now >= 1000) now = 612 + now % 12;
                    result ^= SP[now];
                }
                now = 0;
            }
            if (aux == 1) ++now;
        }
        if (now != 0)
        {
            if (now >= 1000) now = 612 + now % 12;
            result ^= SP[now];
        }

        if (result == 0) fout << "Fumeanu\n";
        else             fout << "Nargy\n";
    }

    fin.close();
    fout.close();
}