103265: [Atcoder]ABC326 F - Robot Rotation

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $525$ points

Problem Statement

A robot is at the origin of a coordinate plane where the positive $x$-axis points to the right and the positive $y$-axis points upwards. Initially, the robot is facing the positive $x$-direction.

You will perform the following operation for $i=1,\ldots,N$ in this order.

  • Rotate the robot $90$ degrees clockwise or counterclockwise. Then, the robot moves forward $A_i$ units in the direction it is facing.

Can the direction of rotation be chosen so that the robot will be at the coordinates $(X,Y)$ after the $N$ operations?

If it is possible, determine which direction, clockwise or counterclockwise, should be chosen for each operation.

Constraints

  • $1 \leq N \leq 80$
  • $1 \leq A_i \leq 10^7$
  • $-10^9\leq X,Y \leq 10^9$
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

$N$ $X$ $Y$
$A_1$ $\ldots$ $A_N$

Output

If the robot cannot be at the coordinates $(X,Y)$ after the $N$ operations, print No.
If the robot can be at the coordinates $(X,Y)$ after the $N$ operations, the first line should contain Yes, and the second line should contain a string $S$ of length $N$ that satisfies the following condition.
Condition: $S$ consists of L and R, and the following choices can put the robot at the coordinates $(X,Y)$ after the $N$ operations: in the $i$-th operation, rotate the robot counterclockwise if the $i$-th character of $S$ is L, and rotate it clockwise if it is R.

If there are multiple solutions, you may print any of them.


Sample Input 1

3 -2 4
3 2 1

Sample Output 1

Yes
LLR

Initially, the robot is at $(0,0)$ and facing the positive $x$-direction. The following choices can put the robot at the coordinates $(X,Y)$ after the $N$ operations.

  • First operation: Rotate the robot $90$ degrees counterclockwise to face the positive $y$-direction. The robot moves forward $A_1=3$ units in the direction it is facing, and moves to $(0,3)$.
  • Second operation: Rotate the robot $90$ degrees counterclockwise to face the negative $x$-direction. The robot moves forward $A_2=2$ units in the direction it is facing, and moves to $(-2,3)$.
  • Third operation: Rotate the robot $90$ degrees clockwise to face the positive $y$-direction. The robot moves forward $A_3=1$ unit in the direction it is facing, and moves to $(-2,4)$.

Diagram


Sample Input 2

1 0 0
1

Sample Output 2

No

Sample Input 3

4 0 0
1 1 1 1

Sample Output 3

Yes
LRRR

Outputs such as LLLL and RRRR are also accepted.


Sample Input 4

14 2543269 -1705099
3 14 159 2653 58979 323846 2643383 2795028 841971 69399 37510 58 20 9

Sample Output 4

Yes
LLLLLLLLLRLRRR

Input

Output

得分:525分

问题描述

一个机器人位于一个坐标平面上,其中正x轴指向右方,正y轴指向上方。最初,机器人面向正x轴方向。

按照以下顺序,为$i=1,\ldots,N$执行以下操作。

  • 将机器人顺时针或逆时针旋转90度。然后,机器人沿着其面向的方向前进$A_i$个单位。

是否可以选择旋转方向,使得机器人在执行完$N$个操作后位于坐标$(X,Y)$?

如果可能,确定每个操作应选择顺时针还是逆时针方向。

限制条件

  • $1 \leq N \leq 80$
  • $1 \leq A_i \leq 10^7$
  • $-10^9\leq X,Y \leq 10^9$
  • 所有输入值都是整数。

输入

输入通过标准输入给出,格式如下:

$N$ $X$ $Y$
$A_1$ $\ldots$ $A_N$

输出

如果机器人无法在执行完$N$个操作后位于坐标$(X,Y)$,打印No

如果机器人可以在执行完$N$个操作后位于坐标$(X,Y)$,第一行应包含Yes,第二行应包含一个长度为$N$的字符串$S$,满足以下条件。

条件:$S$由LR组成,以下选择可以使机器人在执行完$N$个操作后位于坐标$(X,Y)$:在第$i$个操作中,如果$S$的第$i$个字符为L,则将机器人逆时针旋转90度,如果为R,则顺时针旋转。

如果有多种解法,你可以打印其中的任意一种。


样例输入1

3 -2 4
3 2 1

样例输出1

Yes
LLR

最初,机器人位于$(0,0)$,面向正x轴方向。以下选择可以使机器人在执行完$N$个操作后位于坐标$(X,Y)$。

  • 第一个操作:将机器人逆时针旋转90度,面向正y轴方向。机器人沿着其面向的方向前进$A_1=3$个单位,移动到$(0,3)$。
  • 第二个操作:将机器人逆时针旋转90度,面向负x轴方向。机器人沿着其面向的方向前进$A_2=2$个单位,移动到$(-2,3)$。
  • 第三个操作:将机器人顺时针旋转90度,面向正y轴方向。机器人沿着其面向的方向前进$A_3=1$个单位,移动到$(-2,4)$。

Diagram


样例输入2

1 0 0
1

样例输出2

No

样例输入3

4 0 0
1 1 1 1

样例输出3

Yes
LRRR

也接受像LLLLRRRR这样的输出。


样例输入4

14 2543269 -1705099
3 14 159 2653 58979 323846 2643383 2795028 841971 69399 37510 58 20 9

样例输出4

Yes
LLLLLLLLLRLRRR

加入题单

上一题 下一题 算法标签: