Ice and Fire
Little09 and his friends are playing a game. There are n players, and the temperature value of the player i is i.
The types of environment are expressed as 00 or 11. When two players fight in a specific environment, if its type is 00, the player with a lower temperature value in this environment always wins; if it is 11, the player with a higher temperature value in this environment always wins. The types of the n−1−1 environments form a binary string s with a length of n−1−1.
If there are x players participating in the game, there will be a total of x−1−1 battles, and the types of the x−1−1 environments will be the first x−1−1 characters of s. While there is more than one player left in the tournament, choose any two remaining players to fight. The player who loses will be eliminated from the tournament. The type of the environment of battle i is si.
For each x from 22 to n, answer the following question: if all players whose temperature value does not exceed x participate in the game, how many players have a chance to win?
Each test contains multiple test cases. The first line contains a single integer t (1≤t≤1031≤≤103) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer n (2≤n≤2⋅1052≤≤2⋅105) — the number of players.
The second line of each test case contains a binary string s with a length n−1−1.
It is guaranteed that the sum of n over all test cases does not exceed 3⋅1053⋅105.
For each test case output n−1−1 integers — for each x from 22 to n, output the number of players that have a chance to win.
In the first test case, for x=2=2 and x=3=3, only the player whose temperature value is 11 can be the winner. For x=4=4, the player whose temperature value is 2,3,42,3,4 can be the winner.
__EOF__

本文链接:https://www.cnblogs.com/o-Sakurajimamai-o/p/17572945.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话