QOJ.ac

QOJ

Limite de temps : 8 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#17528. Rolling Rick

Statistiques

On a desk, there is a rectangular piece of paper with width $W$ and height $H$. A rectangular parallelepiped named Rick with width $A$, depth $B$, and height $C$ is placed on the paper. Initially, the top-left corner of Rick's base coincides with the top-left corner of the paper.

We can roll Rick to the right or downwards. When rolling Rick, we rotate it around the right or bottom edge of its base. Since Rick's entire surface is covered in wet paint, it leaves paint on the area of the paper it touches. To keep the desk clean, Rick must not be rolled off the paper.

Find the maximum area of the paper covered in paint when moving Rick such that the bottom-right corner of its base coincides with the bottom-right corner of the paper.

Input

The first line contains the dimensions of Rick $A$, $B$, $C$ and the dimensions of the paper $W$, $H$, separated by spaces. ($1 \leq A, B, C, W, H \leq 1\,000\,000$; $A < W$; $B < H$)

All input values are integers.

Output

If it is impossible to move Rick to the bottom-right, output -1 on the first line.

Otherwise, output the maximum area of the painted region on the first line, and the sequence of moves as a string consisting only of R and D on the second line. If the $i$-th character is R, it means rolling Rick to the right; if it is D, it means rolling it downwards.

If there are multiple possible ways, output any one of them.

Examples

Input 1

1 1 1 24 10

Output 1

33
RRRRRRRRRRRRRRRRRRRRRRRDDDDDDDDD

Input 2

3 4 5 6 7

Output 2

-1

Input 3

3 4 5 12 12

Output 3

79
RDRD

Note

The image below illustrates the rolling of Rick in the third example.

In this example, it is possible to roll Rick in the order of down, right, down, right, but the area of the painted region is $74$, which is not optimal.

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.