Gym - 101808I(博弈论)

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

这个单词optimally发挥最佳要理解,就是尽可能的赢

知道一个基本认识,当无法进行操作2时,sum为奇数Yalalov就赢。

然后分情况讨论m , sum 的奇偶性以及可以进行操作二时最小数。

#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;
}

猜你喜欢

转载自www.cnblogs.com/nonames/p/11234617.html