CF379B.New Year Present

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The New Year is coming! That's why many people today are busy preparing New Year presents. Vasily the Programmer is no exception.

Vasily knows that the best present is (no, it's not a contest) money. He's put n empty wallets from left to right in a row and decided how much money to put in what wallet. Vasily decided to put a__i coins to the i-th wallet from the left.

Vasily is a very busy man, so the money are sorted into the bags by his robot. Initially, the robot stands by the leftmost wallet in the row. The robot can follow instructions of three types: go to the wallet that is to the left of the current one (if such wallet exists), go to the wallet that is to the right of the current one (if such wallet exists), put a coin to the current wallet. Due to some technical malfunctions the robot cannot follow two "put a coin" instructions in a row.

Vasily doesn't want to wait for long, so he wants to write a program for the robot that contains at most 106 operations (not necessarily minimum in length) the robot can use to put coins into the wallets. Help him.

新年即将到来!因此,今天许多人正忙着准备新年礼物。程序员瓦西里也不例外。

瓦西里知道,最好的礼物(不,不是一场编程竞赛)是钱。他从左到右排好了 nn 个空钱包,并已决定在每个钱包中放入多少钱。瓦西里决定在从左数第 ii 个钱包中放入 aia_i 枚硬币。

瓦西里非常忙碌,因此他让机器人来完成向钱包中放硬币的工作。初始时,机器人位于这一排钱包中最左侧的钱包旁。机器人可以执行以下三类指令:

  • 向左移动至当前钱包左侧的钱包(若存在);
  • 向右移动至当前钱包右侧的钱包(若存在);
  • 向当前钱包中放入一枚硬币。

但由于某些技术故障,机器人不能连续执行两次“放入硬币”的指令。

瓦西里不想久等,因此他希望编写一个机器人程序,该程序最多包含 10610^6 条指令(不一定要是最短的),使得机器人能按要求将硬币放入各个钱包。请帮助他。

输入格式

The first line contains integer n (2 ≤ n ≤ 300) — the number of wallets. The next line contains n integers _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 300).

It is guaranteed that at least one a__i is positive.

第一行包含一个整数 nn(2≤n≤3002 \leq n \leq 300)—— 钱包的数量。
下一行包含 nn 个整数 a1, a2, ..., ana_1,\,a_2,\,...,\,a_n(0≤ai≤3000 \leq a_i \leq 300)。

保证至少有一个 aia_i 是正数。

输出格式

Print the sequence that consists of k (1 ≤ k ≤ 106) characters, each of them equals: "L", "R" or "P". Each character of the sequence is an instruction to the robot. Character "L" orders to move to the left, character "R" orders to move to the right, character "P" orders the robot to put a coin in the wallet. The robot is not allowed to go beyond the wallet line. In other words, you cannot give instructions "L" if the robot is at wallet 1, or "R" at wallet n.

As a result of the performed operations, the i-th wallet from the left must contain exactly a__i coins. If there are multiple answers, you can print any of them.

输出一个由 k(1 ≤ k ≤ 10⁶)个字符组成的序列,每个字符为 "L"、"R" 或 "P"。序列中的每个字符均表示对机器人的指令:字符 "L" 表示向左移动,字符 "R" 表示向右移动,字符 "P" 表示在当前钱包中放入一枚硬币。机器人不允许越过钱包线。换言之,当机器人位于第 1 个钱包时,不可发出 "L" 指令;当机器人位于第 n 个钱包时,不可发出 "R" 指令。

执行该序列指令后,从左起第 i 个钱包中必须恰好包含 a__i 枚硬币。若存在多种可行解,输出任意一种即可。

输入输出样例

  • 输入#1

    2
    1 2

    输出#1

    PRPLRP
  • 输入#2

    4
    0 2 0 2

    输出#2

    RPRRPLLPLRRRP

输入解题思路,AI测评打分。不知道怎么写?

首页