#P15088. [UOI 2025 II Stage] Digital Game
[UOI 2025 II Stage] Digital Game
题目描述
Vus the Cossack and Us the Cossack are playing a game on a string of length , consisting of digits -.
The players take turns (Vus starts) removing any digit from the string . If at any moment there are two identical digits next to each other in the string, Us wins. If all digits are removed and Us has not won, then Vus wins.
Vus the Cossack is so impatient that even before the game starts, he wants to know if he can win with optimal play (when both players always play to win) against Us, and he has asked you to find this out.
输入格式
The first line contains --- the number of subtests.
In each test case:
The first line contains a single integer .
The second line contains a string of length , consisting only of digits -.
It is guaranteed that the sum of across all subtests does not exceed .
输出格式
For each of the lines, output if Cossack Vus can win; or otherwise.
4
6
015423
7
1235212
4
1111
6
156156
Yes
Yes
No
No
提示
In the first example, two identical digits will never be next to each other, as each digit appears no more than once.
In the second example, Vus can take the last . Then, if Us takes or , Vus takes or respectively, and then all digits become different; thus, Vus will win. However, if Us takes or , then Vus will take any first, and then any .
In the third example, Us wins even before the game starts.
Scoring
- ( points): the number of different digits ;
- ( points): the number of different digits ;
- ( points): the number of different digits ;
- ( points): only one digit appears more than once;
- ( points): if and , then the intervals and do not overlap;
- ( points): ;
- ( points): ;
- ( points): ;
- ( points): ;
- ( points): no additional restrictions.