CF1396B.Stoned Game

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

T is playing a game with his friend, HL.

There are nn piles of stones, the ii-th pile initially has aia_i 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.

T 正在与他的朋友 HL 玩一个游戏。

共有 nn 堆石子,其中第 ii 堆初始时有 aia_i 颗石子。

T 和 HL 轮流进行操作,T 先手。在每一轮中,当前玩家需选择一个非空的石子堆,并从中移除恰好一颗石子。但有一个限制:不能选择上一轮对方所选的那堆石子(若当前为第一轮,则可任选任意一个非空石子堆)。当某位玩家在自己的回合中无法选择任何石子堆时,该玩家判负,游戏结束。

假设双方均以最优策略进行游戏,给定 tt 局游戏各自的初始局面,请判断每局游戏中获胜的一方。

输入格式

The first line of the input contains a single integer tt (1≤t≤100)(1 \le t \le 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 \le n \le 100) — the number of piles.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤100)(1 \le a_i \le 100).

输入的第一行包含一个整数 tt(1≤t≤1001 \le t \le 100)——游戏的场数。随后是各场游戏的描述。每场游戏的描述包含两行:

第一行包含一个整数 nn(1≤n≤1001 \le n \le 100)——堆的数量。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1001 \le a_i \le 100)。

输出格式

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

对于每局游戏,在一行中输出获胜者的名字,“T”或“HL”(不带引号)

输入输出样例

  • 输入#1

    2
    1
    2
    2
    1 1

    输出#1

    T
    HL

说明/提示

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.

在第一局游戏中,T 在他的第一回合从唯一的一堆石子中移除一颗石子。此后,尽管该堆中仍剩 11 颗石子,但 HL 无法从这堆中选择,因为该堆已在上一回合被 T 选过。因此,T 获胜。

输入解题思路,AI测评打分。不知道怎么写?

首页