Robot Detector SOLUTION UKROBOT

Robot Detector SOLUTION UKROBOT

There is a robot in the cell [Math Processing Error] of an infinite grid. One cell [Math Processing Error] contains an obstacle and all other cells are free. We only know that [Math Processing Error] and [Math Processing Error], but not the exact location of the obstacle.

You may give the robot a sequence of instructions. There are four types of instructions:

L: move one cell to the left, i.e. from a cell [Math Processing Error] to [Math Processing Error]

R: move one cell to the right, i.e. from a cell [Math Processing Error] to [Math Processing Error]

D: move one cell down, i.e. from a cell [Math Processing Error] to [Math Processing Error]

U: move one cell up, i.e. from a cell [Math Processing Error] to [Math Processing Error]

The robot attempts to perform these instructions one by one. When performing an instruction, if the cell it needs to move to is free, then it moves to that cell; otherwise, it stays in its current cell.

Consider the following process: you choose a fixed sequence of instructions for the robot, which performs these instructions; then you are given the final cell of the robot and based on only that information, you determine the position of the obstacle. Find a sufficiently short sequence of instructions such that if this process was performed, you would always be able to correctly determine the position of the obstacle. It can be proved that for the given constraints, such a sequence always exists.

 

Input

The first and only line of the input contains two space-separated integers [Math Processing Error] and [Math Processing Error].

 

Output

Print a single line containing one string, which should describe the sequence of instructions for the robot. This string may only contain the characters ‘L’, ‘R’, ‘U’ and ‘D’, and its length must not exceed [Math Processing Error].

 

Constraints

[Math Processing Error]

Subtasks

Subtask #1 (5 points): [Math Processing Error]

Subtask #2 (20 points): [Math Processing Error]

Subtask #3 (75 points): original constraints

 

Example Input

1 2

Example Output

UR

Explanation

If the obstacle is in the cell [Math Processing Error], the robot ends up in the cell [Math Processing Error]. Otherwise, i.e. if the obstacle is in the cell [Math Processing Error], the robot ends up in [Math Processing Error]. The final position of the robot would always be enough to find the obstacle.

 

Related : 

 

March Long Challenge 2021 Solutions

April Long Challenge 2021 Solutions

Codechef Long Challenge Solutions

February Long Challenge 2021

1. Frog Sort Solution Codechef

2. Chef and Meetings Solution Codechef

3. Maximise Function Solution Codechef

4. Highest Divisor Solution Codechef

5. Cut the Cake Challenge Solution Codechef

6. Dream and the Multiverse Solution Codechef

7. Cell Shell Solution Codechef

8. Multiple Games Solution Codechef

9. Another Tree with Number Theory Solution Codechef

10. XOR Sums Solution Codechef

11. Prime Game Solution CodeChef

12. Team Name Solution Codechef

January Long Challenge 2021

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS

RELATED :

Related :

Related :

Leave a Comment