Pagini recente » Cod sursa (job #2823760) | Cod sursa (job #2682157) | Cod sursa (job #3257368) | Cod sursa (job #1250928) | Cod sursa (job #1730085)
#include <fstream>
#include <vector>
#include <bitset>
std::ifstream input_file ( "bowling.in" );
std::ofstream output_file( "bowling.out" );
const int DIM = 2e2 + 5;
std::vector <int> SG( DIM );
std::bitset <DIM> Marked;
void SolveTestCase( void ) {
int N, X, Ans = 0, Nr = 0;
input_file >> N;
for( int i = 1; i <= N; i ++ ) {
input_file >> X;
if( X == 1 )
Nr ++;
if( i == N || X == 0 ) {
Ans = ( Ans ^ ( ( Nr <= 72 ) ? SG[Nr] : SG[ 73 + ( Nr - 73 ) % 12 ] ) );
Nr = 0;
}
}
output_file << ( ( Ans != 0 ) ? "Nargy" : "Fumeanu" ) << "\n";
return;
}
int main( int argc, const char *argv[] ) {
int T; input_file >> T;
for( int i = 0; i <= 2; i ++ )
SG[i] = i;
for( int i = 3; i <= 84; i ++ ) {
Marked.reset();
for( int j = 0; j <= i - 1; j ++ ) {
Marked[ SG[j] ^ SG[i - j - 1] ] = 1;
if( j <= i - 2 )
Marked[ SG[j] ^ SG[i - j - 2] ] = 1;
}
for( int j = 0; j <= 200; j ++ ) {
if( Marked[j] == 0 ) {
SG[i] = j;
break;
}
}
}
for( int i = 1; i <= T; i ++ )
SolveTestCase();
return 0;
}