#x1085. Toy Machine
Toy Machine
Toy Machine
题面翻译
有一个长 宽 的矩形游戏机。保证 是奇数。
游戏开始之前,有 个玩具放在第一排中间的 个位置中(两个角除外)。编号从左到右依次为 到 。第二行为空,其最左、最右和中心位置是障碍物。你可以控制玩具机向左、向右、向上、向下,分别用字母 、、 和 表示。
操控时,所有玩具将同时沿相应方向移动,碰到另一个玩具、墙壁或障碍物停止。您的目标是将第 个玩具移动到第一行最左边。给定 和 ,构造一个最多使用 次操作的方案。
题目描述
There is a toy machine with toys arranged in two rows of cells each ( is odd).
Initial state for .Initially, toys are placed in the non-corner cells of the top row. The bottom row is initially empty, and its leftmost, rightmost, and central cells are blocked. There are buttons to control the toy machine: left, right, up, and down marked by the letters L, R, U, and D correspondingly.
When pressing L, R, U, or D, all the toys will be moved simultaneously in the corresponding direction and will only stop if they push into another toy, the wall or a blocked cell. Your goal is to move the -th toy into the leftmost cell of the top row. The toys are numbered from to from left to right. Given and , find a solution that uses at most button presses.
To test out the toy machine, a web page is available that lets you play the game in real time.
输入格式
The first and only line contains two integers, and ( , is odd, ) — the number of cells in a row, and the index of the toy that has to be moved to the leftmost cell of the top row.
输出格式
On a single line, output a description of the button presses as a string of at most characters. The string should only contain the characters L, R, U, and D. The -th character in the string is the -th button that is pressed. After all the button presses are performed, the -th toy should be in the leftmost cell of the top row.
If there are multiple solutions, print any. The number of button presses does not have to be minimized.
样例 #1
样例输入 #1
5 1
样例输出 #1
RDL
样例 #2
样例输入 #2
7 2
样例输出 #2
RDL
提示
In the first example, there will be toys. The first toy needs to end up in the leftmost cell of the top row. The moves RDL will achieve this, see the picture for a better understanding. Another possible solution would be to do one button press L.
Visualization of the moves for the first example.
相关
在下列比赛中: