Public Judge

pjudge

时间限制: 1 s 内存限制: 1024 MB 总分: 100 可 Hack ✓
统计

Qingyu has a Cartesian coordinate system. There are $2n$ points on the x-axis with coordinates $(0,0), (1,0), \dots, (2n-1,0)$ from left to right. The color of the $i$-th point $(i-1,0)$ is $c_i$. For each $1 \le i \le n$, color $i$ appears exactly twice.

Qingyu wants you to draw $n$ curves on the plane such that the $i$-th curve connects the two points of color $i$. The curves must not intersect each other, and no curve may intersect the line segment connecting $(0,0)$ and $(2n-1,0)$ (except at the endpoints of the curves; note that this implies for $n=1$, connecting $(0,0)$ and $(1,0)$ directly with a segment of length 1 is invalid). "Non-intersecting" means they share no common points. (If you have questions about the definition of intersection, you can read the provided checker.)

In this problem, for ease of output, we define a "curve" as being composed of several segments parallel to the coordinate axes, where the coordinates of the endpoints are integers. See the output format for details. The figure below shows an example:

Input

The first line contains a positive integer $n$.

The second line contains $2n$ positive integers, where the $i$-th integer is $c_i$, representing the color of $(i-1,0)$.

Output

If a connection method exists, output YES on the first line. Otherwise, output NO on the first line. Note that all letters must be uppercase.

If you output YES, you must output $n$ additional lines. The $i$-th line should be formatted as follows:

  • Suppose the two points of color $i$ are $(x,0)$ and $(y,0)$, with $x < y$.
  • The first positive integer is $k$, representing the number of segments the curve connecting $(x,0)$ and $(y,0)$ is divided into.
  • Then, starting from $(x,0)$, describe the $k$ segments in order. Each segment is described by a character (which must be one of L, R, U, D) and a positive integer $z$. L, R, U, D represent moving left ($(-1,0)$), right ($(1,0)$), up ($(0,1)$), and down ($(0,-1)$) respectively, indicating that this segment moves a distance $z$ in that direction from the end of the previous segment (starting from $(x,0)$).

Please refer to the sample output for details. You must ensure that $\sum k \le 2 \times 10^6$, and the absolute value of the coordinates of any point on all output segments does not exceed $10^8$.

If you output YES but the solution is incorrect, you can receive $40\%$ of the points for that test case. Note that even if you cannot output a valid solution, you must still output an answer that follows the format!

If you output NO, you do not need to output anything else.

Examples

Input 1

4
1 2 3 4 1 2 3 4

Output 1

YES
3 U 1 R 4 D 1
5 D 1 L 2 U 3 R 6 D 2
5 D 2 R 6 U 3 L 2 D 1
3 D 1 R 4 U 1

This example is the same as the image in the problem description.

Below is an output that can receive $40\%$ of the points:

YES
1 U 1
1 U 1
1 U 1
1 U 1

Input 2

4
1 2 3 4 1 3 2 4

Output 2

NO

Examples 3, 4

See the provided files. Note that the provided output files only give YES or NO and do not provide specific solutions.

Note

The checker.cpp provided in the files can check if your solution is valid, but it will not check if the YES or NO answer is correct. To use it, place checker.cpp and testlib.h in the same directory, compile to get an executable, place the executable in the same directory as the input and output files, and run checker input output output.

Constraints

This problem uses bundled testing. For all data, $1 \le n \le 2 \times 10^5$, $1 \le c_i \le n$, and each $c_i$ appears exactly twice.

Property A: It is guaranteed that for all test cases where the output is YES, there exists a solution where all output curves do not cross the x-axis.

  • Subtask 1 (5 points): $n \le 2$.
  • Subtask 2 (5 points): $n \le 3$.
  • Subtask 3 (5 points): $n \le 4$.
  • Subtask 4 (5 points): $n \le 7$.
  • Subtask 5 (25 points): $n \le 1000$, Property A.
  • Subtask 6 (25 points): $n \le 1000$.
  • Subtask 7 (10 points): Property A.
  • Subtask 8 (20 points): No special restrictions.

Time limit: 1s Memory limit: 1024MB

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.