QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#12125. 体育课

统计

Dimash 是一位学校的体育老师。目前,他正在给 $2 \cdot n$ 名学生上课。他们准备进行一场游戏,需要分成两队,每队 $n$ 名学生。

游戏开始前,Dimash 将所有 $2 \cdot n$ 名学生排成一排,第一队的学生穿红色 T 恤,第二队的学生穿蓝色 T 恤。接着,每位穿红色 T 恤的学生向左看,计算自己颜色的学生人数与对方颜色的学生人数之差。同样地,每位穿蓝色 T 恤的学生向右看,计算自己颜色的学生人数与对方颜色的学生人数之差。注意,差值是有符号的,可以是正数也可以是负数。

所有学生从左到右依次报出了他们计算出的数字。Dimash 将这些数字记录在一个列表中,但顺序被打乱了。请根据这份记录,找出任何一种可能符合条件的排队方式。如果存在多种合法的答案,输出其中任意一种即可。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 3 \cdot 10^5$),表示测试用例的数量。接下来是各测试用例的描述。

每个测试用例的第一行包含一个整数 $n$ ($1 \le n \le 3 \cdot 10^5$),表示每队的队员人数。

每个测试用例的第二行包含 $2 \cdot n$ 个整数 $a_1, a_2, \dots, a_{2n}$ ($-n \le a_i \le n$),即 Dimash 记录的列表。

保证所有测试用例的 $n$ 之和不超过 $3 \cdot 10^5$。

保证 Dimash 给出的列表是正确的,即答案一定存在。

输出格式

对于每个测试用例,输出一个长度为 $2 \cdot n$ 的字符串。如果第 $i$ 个学生穿红色 T 恤并向左看,则第 $i$ 个字符为 'L';如果第 $i$ 个学生穿蓝色 T 恤并向右看,则第 $i$ 个字符为 'R'。

子任务

本题包含 6 个子任务。

子任务 附加限制 分值
0 样例 0
1 $t \le 10, n = 2$ 11
2 $t \le 10, n \le 10$ 15
3 所有 $a_i$ 相等 9
4 保证 Dimash 的列表未被打乱 16
5 $t \le 2000, \sum n \le 2000$ 20
6 29

$\sum n$ 表示所有输入数据集中 $n$ 的总和。

样例

输入 1

2
2
1 1 0 0
4
-2 0 -2 -1 -2 -1 -2 0

输出 1

LLRR
LRRRLRLL

说明

在第一组输入数据中,Dimash 的学生结构可能是 “LLRR”,由此他会得到列表 $[0, 1, 1, 0]$,但在打乱顺序后,他可能得到列表 $[1, 1, 0, 0]$。

在第二组输入数据中,Dimash 的学生结构可能是 “LRRRLRLL”,由此他会得到列表 $[0, 0, -1, -2, -2, -2, -2, -1]$,但在打乱顺序后,他可能得到列表 $[-2, 0, -2, -1, -2, -1, -2, 0]$。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.