A15612 | Ice and Fire
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $0$ or $1$ . When two players fight in a specific environment, if its type is $0$ , the player with a lower temperature value in this environment always wins; if it is $1$ , the player with a higher temperature value in this environment always wins. The types of the $n-1$ environments form a binary string $s$ with a length of $n-1$ .
If there are $x$ players participating in the game, there will be a total of $x-1$ battles, and the types of the $x-1$ environments will be the first $x-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 $s_i$ .
For each $x$ from $2$ 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?
The types of environment are expressed as $0$ or $1$ . When two players fight in a specific environment, if its type is $0$ , the player with a lower temperature value in this environment always wins; if it is $1$ , the player with a higher temperature value in this environment always wins. The types of the $n-1$ environments form a binary string $s$ with a length of $n-1$ .
If there are $x$ players participating in the game, there will be a total of $x-1$ battles, and the types of the $x-1$ environments will be the first $x-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 $s_i$ .
For each $x$ from $2$ 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\le t \le 10^3$ ) — 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\leq n\leq 2\cdot 10^5$ ) — the number of players.
The second line of each test case contains a binary string $s$ with a length $n-1$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $3\cdot 10^5$ .
The first line of each test case contains a single integer $n$ ( $2\leq n\leq 2\cdot 10^5$ ) — the number of players.
The second line of each test case contains a binary string $s$ with a length $n-1$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $3\cdot 10^5$ .
输出格式
For each test case output $n-1$ integers — for each $x$ from $2$ to $n$ , output the number of players that have a chance to win.
输入输出样例
输入 #1
2 4 001 4 101
输出 #1
1 1 3 1 2 3
In the first test case, for $x=2$ and $x=3$ , only the player whose temperature value is $1$ can be the winner. For $x=4$ , the player whose temperature value is $2,3,4$ can be the winner.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted