#x1085. Toy Machine

    ID: 5998 远端评测题 1000ms 256MiB 尝试: 7 已通过: 3 难度: 10 上传者: 标签>constructive algorithmsgamesimplementation*2700

Toy Machine

Toy Machine

题面翻译

有一个长 nn22 的矩形游戏机。保证 nn 是奇数。

游戏开始之前,有 n2n - 2 个玩具放在第一排中间的 n2n - 2 个位置中(两个角除外)。编号从左到右依次为 11n2n - 2。第二行为空,其最左、最右和中心位置是障碍物。你可以控制玩具机向左、向右、向上、向下,分别用字母 L\texttt LR\texttt RU\texttt UD\texttt D 表示。

操控时,所有玩具将同时沿相应方向移动,碰到另一个玩具、墙壁或障碍物停止。您的目标是将第 kk 个玩具移动到第一行最左边。给定 nnkk,构造一个最多使用 10000001000000 次操作的方案。

题目描述

There is a toy machine with toys arranged in two rows of n n cells each ( n n is odd).

Initial state for n=9 n=9 .Initially, n2 n-2 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 4 4 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 k k -th toy into the leftmost cell of the top row. The toys are numbered from 1 1 to n2 n-2 from left to right. Given n n and k k , find a solution that uses at most 1000000 1\,000\,000 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, n n and k k ( 5n100000 5 \le n \le 100\,000 , n n is odd, 1kn2 1 \le k \le n-2 ) — 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 1000000 1\,000\,000 characters. The string should only contain the characters L, R, U, and D. The i i -th character in the string is the i i -th button that is pressed. After all the button presses are performed, the k k -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 52=3 5-2 = 3 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.