#P15783. [JAG 2025 Summer Camp #3] Ants Collision

[JAG 2025 Summer Camp #3] Ants Collision

题目描述

There are NN ants on a number line. The ii-th ant is initially at coordinate ii and is stationary. Each ant faces either right (the positive direction) or left (the negative direction), but the initial directions are unknown.

At time 00, each ant starts moving at a speed of 11 per unit time. Whenever two ants collide (i.e., occupy the same position), they turn around and move in the opposite direction.

By time 1010010^{100}, the ii-th ant has collided with other ants exactly AiA_i times.

Determine whether there exists an assignment of initial directions for the ants that is consistent with these collision counts. If such an assignment exists, construct one.

输入格式

The input consists of multiple test cases.

The first line contains an integer TT (1T100001 \leq T \leq 10000), representing the number of test cases.

TT test cases follow. Each test case is given in the following format.

$$\begin{aligned} &N \\ &A_1 \ A_2 \ \ldots \ A_N \end{aligned} $$

For each test case, the first line contains an integer NN (1N3000001 \leq N \leq 300000), representing the number of ants.

The next line contains NN integers A1,A2,,ANA_1, A_2, \ldots, A_N (0Ai1090 \leq A_i \leq 10^9), each representing the number of times the corresponding ant has collided with other ants by time 1010010^{100}.

Additionally, the sum of NN over all test cases does not exceed 300000300000.

输出格式

Output TT lines. For each test case, determine whether there exists an assignment of initial directions for the ants that satisfies the conditions described in the problem.

  • If no such assignment exists, output "No".
  • If an assignment exists, output a string of length NN consisting of characters 'L' and 'R', where the ii-th character is 'L' if the ii-th ant initially faces left (the negative direction), and 'R' if it initially faces right (the positive direction).

If multiple assignments exist, any of them will be accepted.

3
3
1 2 1
5
3 1 4 1 5
4
0 0 0 0
RRL
No
LLLL