CF1476F.Lanterns
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n lanterns in a row. The lantern i is placed in position i and has power equal to pi.
Each lantern can be directed to illuminate either some lanterns to the left or some lanterns to the right. If the i-th lantern is turned to the left, it illuminates all such lanterns j that j∈[i−pi,i−1]. Similarly, if it is turned to the right, it illuminates all such lanterns j that j∈[i+1,i+pi].
Your goal is to choose a direction for each lantern so each lantern is illuminated by at least one other lantern, or report that it is impossible.
一行中有 n 个灯笼。第 i 个灯笼位于位置 i,其亮度(功率)为 pi。
每个灯笼可以朝左或朝右照射,以照亮其左侧或右侧的若干灯笼。若第 i 个灯笼朝左,则它照亮所有满足 j∈[i−pi,i−1] 的灯笼 j;若朝右,则它照亮所有满足 j∈[i+1,i+pi] 的灯笼 j。
你的目标是为每个灯笼选定一个方向,使得每个灯笼至少被另一个灯笼照亮;若无法实现,请报告不可能。
输入格式
The first line contains one integer t (1≤t≤10000) — the number of test cases.
Each test case consists of two lines. The first line contains one integer n (2≤n≤3⋅105) — the number of lanterns.
The second line contains n integers p1,p2,…,pn (0≤pi≤n) — the power of the i-th lantern.
The sum of n over all test cases does not exceed 3⋅105.
第一行包含一个整数 t(1≤t≤10000)—— 测试用例的数量。
每个测试用例由两行组成。第一行包含一个整数 n(2≤n≤3⋅105)—— 灯笼的数量。
第二行包含 n 个整数 p1,p2,…,pn(0≤pi≤n)—— 第 i 个灯笼的功率。
所有测试用例中 n 的总和不超过 3⋅105。
输出格式
For each test case, print the answer as follows:
If it is possible to direct all lanterns so that each lantern is illuminated, print YES in the first line and a string of n characters L and/or R (the i-th character is L if the i-th lantern is turned to the left, otherwise this character is R) in the second line. If there are multiple answers, you may print any of them.
If there is no answer, simply print NO for that test case.
对于每个测试用例,请按如下方式输出答案:
如果可以调整所有灯笼的方向,使得每个灯笼均被照亮,则在第一行输出 YES,在第二行输出一个长度为 n 的字符串,该字符串仅由字符 L 和/或 R 组成(其中第 i 个字符为 L 表示第 i 个灯笼朝左,否则为 R)。若存在多个可行解,输出任意一个即可。
若不存在满足条件的方案,则对该测试用例仅输出 NO。
输入输出样例
输入#1
4 8 0 0 3 1 1 1 1 2 2 1 1 2 2 2 2 0 1
输出#1
YES RRLLLLRL YES RL YES RL NO
输入解题思路,AI测评打分。不知道怎么写?