B. Stoned Game 博弈论

Problem - B - Codeforces

B. Stoned Game

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

T is playing a game with his friend, HL.

There are nn piles of stones, the ii-th pile initially has aiai stones.

T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile that has been chosen in the previous turn (the pile that was chosen by the other player, or if the current turn is the first turn then the player can choose any non-empty pile). The player who cannot choose a pile in his turn loses, and the game ends.

Assuming both players play optimally, given the starting configuration of tt games, determine the winner of each game.

Input

The first line of the input contains a single integer tt (1≤t≤100)(1≤t≤100) — the number of games. The description of the games follows. Each description contains two lines:

The first line contains a single integer nn (1≤n≤100)(1≤n≤100) — the number of piles.

The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤100)(1≤ai≤100).

Output

For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)

Example

input

Copy

2
1
2
2
1 1

output

Copy

T
HL

Note

In the first game, T removes a single stone from the only pile in his first turn. After that, although the pile still contains 11 stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner.

=========================================================================

数据范围很小,可以直接找结论也可以模拟,那就是每次都选择上个人没选择的最大的,至于证明,不会

# include<bits/stdc++.h>

using namespace std;
# define mod 1000000007
typedef long long int ll;

int a[100];

bool cmp(int x,int y)
{
    return x>y;
}
int main ()
{


   int t;
   cin>>t;

   while(t--)
   {
       int n;
       cin>>n;

       for(int i=1;i<=n;i++)
       {
           cin>>a[i];
       }

       sort(a+1,a+1+n,cmp);

       int pre=0,now=1;

       int ans=1;

       while(1)
       {

          int maxx=0,id=0;

          for(int i=1;i<=n;i++)
          {
              if(i!=pre)
              {
                  if(a[i]>a[id])
                  {
                      id=i;

                  }
              }
          }
          if(id==0)
          {
             ans=now;
             break;
          }
          a[id]--;
          pre=id;
          now=3-now;
       }

       if(ans==1)
       {
           cout<<"HL"<<endl;
       }
       else
       {
           cout<<"T"<<endl;
       }
   }
    return 0;

}


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qinsanma and Code

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值