Cod sursa(job #1092933)

Utilizator crisbodnarCristian Bodnar crisbodnar Data 27 ianuarie 2014 16:24:28
Problema Bowling Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.14 kb
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>

using namespace std;

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

int T, N, S, V[105];
vector <bool> uz(105);

int Period(int x)
{
    return x < 72 ? x : (x % 12) + 72;
}

void Prec_SG()
{
    //V[1] = 1;
    for(int i = 1; i <= 83; i++)
    {
        for(int j = 1, lim = (i >> j) + 1; j <= lim; j++)
            uz[V[i - j] ^ V[i - (i - j) - 1]] = uz[V[i - j - 1] ^ V[i - (i - j) - 1]] = true;
        for(int k = 0; k <= 10; k++)
            if(!uz[k])
            {
                V[i] = k;
                break;
            }
        //cout<<V[i]<<endl;
        uz.assign(12, 0);
    }
}

int main()
{
    fin >> T;
    Prec_SG();
    while(T--)
    {
        fin >> N; int lg = 0; S = 0;
        for(int i = 1; i <= N; i++)
        {
            int x; fin >> x;
            if(x) lg++;
            else
                if(lg) S ^= V[Period(lg)], lg = 0;
        }
        if(lg) S ^= V[Period(lg)];
        if(S) fout << "Nargy";
        else fout << "Fumeanu";
        fout << '\n';
    }
    return 0;
}