Gym - 101808I (Game Theory)

http://codeforces.com/gym/101808/problem/I

Ildar Yalalov is a famous eagle with the head of an uzbek guy. He is a very famous competitive programmer in Russia.

But what people don't know that his friend Sergey was feeding him for 3 months so that his wings grow. Few months ago Yalalov was in the top 20 in some VK cup round. In the next round he missed solving 1 problem because he forgot how to use setprecision function properly.

Sergey was very angry, because he spent all these months training Yalalov and growing his wings but for nothing so he decided to quit that and moved on to some other talented guys.

Ildar decided to challenge Sergey to some game to prove that Sergey is no more than a beginner problem-solver.

There are N piles of stones, the ith pile contains Ai stones. Ildar and Sergey are playing a game, they take turns and Ildar starts the first move.

In each turn, the current player has two options:

1) Remove one stone from any pile.

2) Remove one stone from every pile if every pile has at least 1 stone.

The player who can't make a move loses. Can you determine the winner if both players play optimally?

Print "Yalalov" if Ildar Yalalov wins, and "Shin" otherwise.


Input

The first line contains a single integer T, the number of test cases.

Each test case starts with a line containing a single integer N, the number of piles. (1 ≤ N ≤ 100)

The following line contains N space-separated integers Ai, the number of stones in each pile. (1 ≤ Ai ≤ 106)

Output

For each test case, print "Yalalov" if Ildar Yalalov wins the game, and "Shin" otherwise.

Example
Input
1
2
1 2
Output
Yalalov
Note

ildar Yalalov

The best word to play optimally is to be understood that as much as possible to win

A basic understanding to know, when not operated 2, sum odd Yalalov win.

Then the discussion points m, and the parity of the sum of the minimum number of two may be performed during operation.

 

#include <iostream>
#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;

int a[109] ;

int main()
{
    int n ;
    scanf("%d" , &n);
    while(n--)
    {
        int m , x; 
        cin >> m ;
        int sum = 0 ;
        for(int i = 0 ; i < m ; i++)
        {
            cin >> a[i];
            sum += a[i];
        }
        sort(a , a + m);
        x = a[0] ;
        if(m % 2 == 1)
        {
            if(sum % 2 == 1)
                cout << "Yalalov" << endl ;
            else
                cout << "Shin" << endl ;
        }
        else
        {
            if(sum % 2 == 1)
                cout << "Yalalov" << endl ;
            else
            {
                if(x % 2 == 1)
                    cout << "Yalalov" << endl;
                else
                    cout << "Shin" << endl;
                    
            }
        }
    }


    return 0;
}

 

 

 

Guess you like

Origin www.cnblogs.com/nonames/p/11234617.html