#abc326f. F - Robot Rotation

F - Robot Rotation

Score : 525525 points

问题描述

一个机器人位于坐标平面的原点,其中正 xx 轴指向右侧,正 yy 轴指向上方。最初,机器人面向正 xx 轴方向。

您将按照以下顺序执行从 i=1,,Ni=1,\ldots,N 的操作:

  • 使机器人顺时针或逆时针旋转 9090 度。然后,机器人按照它所面对的方向向前移动 AiA_i 个单位。

是否存在一种选择旋转方向的方式,使得在 NN 次操作后,机器人能够到达坐标 (X,Y)(X,Y)

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

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

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

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

  • Rotate the robot 9090 degrees clockwise or counterclockwise. Then, the robot moves forward AiA_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)(X,Y) after the NN operations?

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

Constraints

  • 1N801 \leq N \leq 80
  • 1Ai1071 \leq A_i \leq 10^7
  • 109X,Y109-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:

NN XX YY

A1A_1 \ldots ANA_N

Output

If the robot cannot be at the coordinates (X,Y)(X,Y) after the NN operations, print No.
If the robot can be at the coordinates (X,Y)(X,Y) after the NN operations, the first line should contain Yes, and the second line should contain a string SS of length NN that satisfies the following condition.
Condition: SS consists of L and R, and the following choices can put the robot at the coordinates (X,Y)(X,Y) after the NN operations: in the ii-th operation, rotate the robot counterclockwise if the ii-th character of SS 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)(0,0) and facing the positive xx-direction. The following choices can put the robot at the coordinates (X,Y)(X,Y) after the NN operations.

  • First operation: Rotate the robot 9090 degrees counterclockwise to face the positive yy-direction. The robot moves forward A1=3A_1=3 units in the direction it is facing, and moves to (0,3)(0,3).
  • Second operation: Rotate the robot 9090 degrees counterclockwise to face the negative xx-direction. The robot moves forward A2=2A_2=2 units in the direction it is facing, and moves to (2,3)(-2,3).
  • Third operation: Rotate the robot 9090 degrees clockwise to face the positive yy-direction. The robot moves forward A3=1A_3=1 unit in the direction it is facing, and moves to (2,4)(-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

update @ 2024/3/10 01:50:08