CF1774C.Ice and Fire

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Little09 and his friends are playing a game. There are nn players, and the temperature value of the player ii is ii.

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−1n-1 environments form a binary string ss with a length of n−1n-1.

If there are xx players participating in the game, there will be a total of x−1x-1 battles, and the types of the x−1x-1 environments will be the first x−1x-1 characters of ss. 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 ii is sis_i.

For each xx from 22 to nn, answer the following question: if all players whose temperature value does not exceed xx participate in the game, how many players have a chance to win?

Little09 和他的朋友们正在玩一个游戏。共有 nn 名玩家,玩家 ii 的温度值为 ii。

环境类型用 00 或 11 表示。当两名玩家在特定环境中对战时:若该环境类型为 00,则温度值较低的玩家总是获胜;若该环境类型为 11,则温度值较高的玩家总是获胜。n−1n-1 个环境的类型构成一个长度为 n−1n-1 的二进制字符串 ss。

若共有 xx 名玩家参与游戏,则总共进行 x−1x-1 场对战,这 x−1x-1 场对战所处环境的类型依次为 ss 的前 x−1x-1 个字符。只要游戏中剩余玩家数大于 11,就任选两名剩余玩家进行对战,失败者将被淘汰。第 ii 场对战所处环境的类型为 sis_i。

对每个从 22 到 nn 的 xx,回答以下问题:若所有温度值不超过 xx 的玩家均参与游戏,则有多少名玩家有可能获胜?

输入格式

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1031\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 nn (2≤n≤2⋅1052\leq n\leq 2\cdot 10^5) — the number of players.

The second line of each test case contains a binary string ss with a length n−1n-1.

It is guaranteed that the sum of nn over all test cases does not exceed 3⋅1053\cdot 10^5.

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤1031\le t \le 10^3)—— 测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(2≤n≤2⋅1052\leq n\leq 2\cdot 10^5)—— 玩家数量。

每个测试用例的第二行包含一个长度为 n−1n-1 的二进制字符串 ss。

保证所有测试用例的 nn 值之和不超过 3⋅1053\cdot 10^5。

输出格式

For each test case output n−1n-1 integers — for each xx from 22 to nn, output the number of players that have a chance to win.

对于每个测试用例,输出 n−1n-1 个整数——对每个从 22 到 nn 的 xx,输出可能获胜的玩家数量。

输入输出样例

  • 输入#1

    2
    4
    001
    4
    101

    输出#1

    1 1 3 
    1 2 3

说明/提示

In the first test case, for x=2x=2 and x=3x=3, only the player whose temperature value is 11 can be the winner. For x=4x=4, the player whose temperature value is 2,3,42,3,4 can be the winner.

在第一个测试用例中,当 x=2x=2 和 x=3x=3 时,只有温度值为 11 的玩家可以获胜;当 x=4x=4 时,温度值为 2,3,42,3,4 的玩家可以获胜。

输入解题思路,AI测评打分。不知道怎么写?

首页