Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MUST SOLVE IN JAVA Little09 and his friends are playing a game. There are n players, and the temperature value of the player i is

image text in transcribed

MUST SOLVE IN JAVA

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 n1 environments form a binary string s with a length of n1. If there are x players participating in the game, there will be a total of x1 battles, and the types of the x1 environments will be the first x1 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 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? Input Each test contains multiple test cases. The first line contains a single integer t(1t103) the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n(2n2105) - the number of players. The second line of each test case contains a binary string s with a length n1. It is guaranteed that the sum of n over all test cases does not exceed 3105. Output For each test case output n1 integers - for each x from 2 to n, output the number of players that have a chance to win. Fxamnla 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

Students also viewed these Databases questions

Question

RP-1 How did the humanistic theories provide a fresh perspective?

Answered: 1 week ago