UVa : 11892 (ENimEN)



// http://uva.onlinejudge.org/external/118/11892.html
// Runtime : 0.064s
// Tag : Nim, Game Theory 

// @BEGIN_OF_SOURCE_CODE

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#define INT_MAX 2147483647
#define INT_MIN -2147483647
#define pi acos(-1.0)
#define N 1000000
#define LL unsigned long long
using namespace std;


int main ()
{
	int testCase;
	scanf ("%d", &testCase);

	while ( testCase-- ) {
		int n;
		scanf ("%d", &n);

		int input;
		int cntOne = 0;
		int cntOthers = 0;

		for ( int i = 0; i < n; i++ ) {
			scanf ("%d", &input);
			if ( input == 1 ) cntOne++;
			else cntOthers++;
		}

		if ( cntOne % 2 ) printf ("poopi\n");
		else {
			if ( cntOthers > 0 ) printf ("poopi\n");
			else printf ("piloop\n");
		}

	} // while loop for testCase

	return 0;
} // end of main ()

// @END_OF_SOURCE_CODE

One thought on “UVa : 11892 (ENimEN)

  1. Hints : 
    1. Odd number of 1 is definitely the winning state 
    2. Even number of 1 might be a winning state 
    if there are other numbers 
    otherwise, even number of 1 is a loosing state 
    
    Critical Input : 
    6
    2 
    100 1
    2
    100 100
    4
    1 1 100 100 
    3
    1 100 100
    3
    1 1 100
    4
    1 1 1 1
    Output : 
    poopi
    poopi
    poopi
    poopi
    poopi
    piloop
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s