Codeforces Round 942 (Div. 2)
B
Coin Games
Codeforces
900
原题
← AC →
翻译中…

There are $n$ coins on the table forming a circle, and each coin is either facing up or facing down. Alice and Bob take turns to play the following game, and Alice goes first.

翻译中…

In each operation, the player chooses a facing-up coin, removes the coin, and flips the two coins that are adjacent to it. If (before the operation) there are only two coins left, then one will be removed and the other won't be flipped (as it would be flipped twice). If (before the operation) there is only one coin left, no coins will be flipped. If (before the operation) there are no facing-up coins, the player loses.

翻译中…

Decide who will win the game if they both play optimally. It can be proved that the game will end in a finite number of operations, and one of them will win.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\le t\le 100$). The description of the test cases follows.

翻译中…

The first line of each test case contains only one positive integer $n$ ($1 \leq n \leq 100$), representing the number of the coins.

翻译中…

A string $s$ of length $n$ follows on the second line of each test case, containing only "U" and "D", representing that each coin is facing up or facing down.

翻译中…

Output

翻译中…

For each test case, print "YES" if Alice will win the game, and "NO" otherwise.

翻译中…

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

翻译中…

Note

翻译中…

In the first test case, the game may go as follows.

翻译中…
  • Alice chooses the first coin and $s$ becomes "DDUU".
  • Bob chooses the last coin and $s$ becomes "UDD".
  • Alice chooses the first coin and $s$ becomes "UU".
  • Bob chooses the first coin and $s$ becomes "U".
  • Alice chooses the only coin and $s$ becomes empty.
  • Bob can't choose any coin now, and he loses the game.
翻译中…

It can be proved that Bob will always lose if they both play optimally.

翻译中…

样例

Input #1
3
5
UUDUD
5
UDDUD
2
UU
Output #1
YES
NO
NO
InputCopy OutputCopy
题目信息
题号
1972B
时间限制
1 s
内存限制
256 MB
标签
博弈论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。