#P15088. [UOI 2025 II Stage] Digital Game

    ID: 17004 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>搜索博弈论2025Ad-hocUOI(乌克兰)

[UOI 2025 II Stage] Digital Game

题目描述

Vus the Cossack and Us the Cossack are playing a game on a string ss of length nn, consisting of digits 00-99.

The players take turns (Vus starts) removing any digit from the string ss. 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 tt (1t10)(1\leq t \leq 10) --- the number of subtests.

In each test case:

The first line contains a single integer nn (1n106)(1\leq n \leq 10^6).

The second line contains a string ss of length nn, consisting only of digits 00-99.

It is guaranteed that the sum of nn across all subtests does not exceed 10610^6.

输出格式

For each of the tt lines, output Yes\tt{Yes} if Cossack Vus can win; or No\tt{No} 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 22. Then, if Us takes 11 or 22, Vus takes 22 or 11 respectively, and then all digits become different; thus, Vus will win. However, if Us takes 33 or 55, then Vus will take any 22 first, and then any 11.

In the third example, Us wins even before the game starts.

Scoring

  • (88 points): the number of different digits 2\leq 2;
  • (88 points): the number of different digits 5\leq 5;
  • (66 points): the number of different digits 7\leq 7;
  • (88 points): only one digit appears more than once;
  • (77 points): if sl=sr,si=sjs_l=s_r, s_i=s_j and sisls_i \neq s_l (lr;ij)(l\neq r; i\neq j), then the intervals [l,r][l, r] and [i,j][i, j] do not overlap;
  • (77 points): n4n \leq 4;
  • (66 points): n8n \leq 8;
  • (66 points): n12n \leq 12;
  • (66 points): n15n \leq 15;
  • (3838 points): no additional restrictions.