A13752 | Stoned Game
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
T is playing a game with his friend, HL.
There are $n$ piles of stones, the $i$ -th pile initially has $a_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 $t$ games, determine the winner of each game.
There are $n$ piles of stones, the $i$ -th pile initially has $a_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 $t$ games, determine the winner of each game.
输入格式
The first line of the input contains a single integer $t$ $(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 $n$ $(1 \le n \le 100)$ — the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$ .
The first line contains a single integer $n$ $(1 \le n \le 100)$ — the number of piles.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ $(1 \le a_i \le 100)$ .
输出格式
For each game, print on a single line the name of the winner, "T" or "HL" (without quotes)
输入输出样例
输入 #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 $1$ stone, HL cannot choose from this pile because it has been chosen by T in the previous turn. Therefore, T is the winner.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted