#P11282. 「GFOI Round 2」Colors
「GFOI Round 2」Colors
Description
There are balls arranged in a row, numbered from to from left to right. Initially, each ball is red. The initial weight of the -th ball is . It is guaranteed that is an odd number and that is a permutation of .
You need to perform exactly operations. In one operation, you must:
- Choose a red ball such that there is at least one red ball in the range and at least one red ball in the range .
- Let be the largest integer such that and the ball at position is red, and let be the smallest integer such that and the ball at position is red. You will paint both balls and blue.
- Then, perform exactly one of the following two operations:
- Modify (the weight of ball ) to ;
- Modify (the weight of ball ) to .
After performing operations, there will be exactly one red ball left.
You need to determine for each positive integer in the range to whether it is possible to perform the operations in such a way that the weight of the remaining red ball is .
Input Format
This problem has multiple test cases in a single test.
The first line contains a positive integer , indicating the number of test cases.
For each test case:
- The first line contains a positive integer .
- The second line contains positive integers .
Output Format
For each test case, output a line containing a string. For each positive integer in the range , if it is possible to perform the operations in such a way that the weight of the remaining red ball is , then the -th position of this string will be ; otherwise, it will be .
4
3
3 2 1
5
1 3 5 2 4
5
5 4 3 1 2
9
4 7 3 6 1 2 5 8 9
101
11111
11101
111111101
Hint
Sample Explanation
For the first test case, the initial state of the balls (color and weight) is .
You need to perform operation. In this operation, you can only choose ball and paint both balls and blue.
- If you choose to modify to , then after the operation, the state of the balls will be , and the weight of the remaining red ball will be ;
- If you choose to modify to , then after the operation, the state of the balls will be , and the weight of the remaining red ball will be .
Thus, you will output a string that has s at the st and rd positions, and s in the other positions.
For the second test case, it can be easily proven that the weight of the remaining red ball can take all positive integers from to . Here is an example of a sequence of operations that results in the remaining red ball having a weight of :
- The initial state of the balls is .
- Choose ball , paint both balls and blue, and set to . After this operation, the state of the balls becomes $\color{red}{5}\ \color{blue}{3\ 5}\ \color{red}{2\ 4}$.
- Choose ball , paint both balls and blue, and set to . After this operation, the state of the balls becomes .
Subtasks and Constraints
| Subtask ID | Special Properties | Score | ||
|---|---|---|---|---|
| No | ||||
| A | ||||
| No |
- Special Property A: .
For all tests, it is guaranteed that:
- ;
- and is an odd number;
- ;
- is a permutation of .
京公网安备 11011102002149号