atcoder#DDCC2020QUALE. Majority of Balls
Majority of Balls
Score: points
Problem Statement
This is an interactive task.
We have balls arranged in a row, numbered from left to right, where is an odd number. Among them, there are red balls and blue balls.
While blindfolded, you are challenged to guess the color of every ball correctly, by asking at most questions of the following form:
- You choose any of the balls and ask whether there are more red balls than blue balls or not among those balls.
Now, let us begin.
Constraints
- is an odd number.
Input and Output
First, receive the number of balls of each color, , from Standard Input:
N
Then, ask questions until you find out the color of every ball. A question should be printed to Standard Output in the following format:
? A_1 A_2 A_3 ... A_N
This means that you are asking about the balls , where and must hold.
The response to this question will be given from Standard Input in the following format:
T
Here is one of the following strings:
Red
: Among the balls chosen, there are more red balls than blue balls.Blue
: Among the balls chosen, there are more blue balls than red balls.-1
: You printed an invalid question (including the case you asked more than questions), or something else that was invalid.
If the judge returns -1
, your submission is already judged as incorrect. The program should immediately quit in this case.
When you find out the color of every ball, print your guess to Standard Output in the following format:
! c_1c_2c_3...c_{2N}
Here should be the character representing the color of Ball ; use R
for red and B
for blue.
Notice
- Flush Standard Output each time you print something. Failure to do so may result in
TLE
. - Immediately terminate your program after printing your guess (or receiving the
-1
response). Otherwise, the verdict will be indeterminate. - If your program prints something invalid, the verdict will be indeterminate.
Sample Input and Output
Input | Output |
---|---|
3 |
|
? 1 2 3 |
|
Red |
|
? 2 4 6 |
|
Blue |
|
! RRBBRB |
In this sample, , and the colors of Ball are red, red, blue, blue, red, blue, respectively.
- In the first question, there are two red balls and one blue ball among the balls , so the judge returns
Red
. - In the second question, there are one red ball and two blue balls among the balls , so the judge returns
Blue
.