CF1817D.Toy Machine

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

Initial state for n=9n=9.

Initially, n−2n-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 44 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 kk-th toy into the leftmost cell of the top row. The toys are numbered from 11 to n−2n-2 from left to right. Given nn and kk, find a solution that uses at most 1 000 0001\,000\,000 button presses.

To test out the toy machine, a web page is available that lets you play the game in real time.

有一个玩具机器,玩具排列在两行中,每行有 nn 个格子(nn 为奇数)。

n=9n=9 时的初始状态。

初始时,上排除左右两端外的 n−2n-2 个格子中各放置一个玩具。下排初始为空,且其最左、最右和正中间的格子被封锁。该玩具机器有 4 个控制按钮:左(L)、右(R)、上(U)和下(D)。

当按下 L、R、U 或 D 按钮时,所有玩具将同时向对应方向移动,直至碰到另一个玩具、墙壁或被封锁的格子时才停止。你的目标是将第 kk 个玩具移入上排最左侧的格子中。玩具从左到右依次编号为 11 至 n−2n-2。给定 nn 和 kk,请找出一种最多使用 1 000 0001\,000\,000 次按钮按压的操作方案。

为便于体验该玩具机器,提供了一个网页,你可实时进行游戏。

输入格式

The first and only line contains two integers, nn and kk (5≤n≤100 0005 \le n \le 100\,000, nn is odd, 1≤k≤n−21 \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.

第一行且唯一一行包含两个整数 nn 和 kk(5≤n≤100 0005 \le n \le 100\,000,nn 为奇数,1≤k≤n−21 \le k \le n-2)—— 分别表示一行中的单元格数量,以及需要移动至顶行最左端单元格的玩具的编号。

输出格式

On a single line, output a description of the button presses as a string of at most 1 000 0001\,000\,000 characters. The string should only contain the characters L, R, U, and D. The ii-th character in the string is the ii-th button that is pressed. After all the button presses are performed, the kk-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 000 0001\,000\,000 个字符的字符串。字符串中仅可包含字符 L、R、U 和 D。字符串中第 ii 个字符表示第 ii 次按下的按钮。在执行完所有按钮按压操作后,第 kk 个玩具应位于顶行最左侧的格子中。

若存在多个解,输出任意一个即可。按钮按压次数无需最小化。

输入输出样例

  • 输入#1

    5 1

    输出#1

    RDL
  • 输入#2

    7 2

    输出#2

    RDL

说明/提示

In the first example, there will be 5−2=35-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.

在第一个例子中,将剩下 5−2=35-2 = 3 个玩具。第一个玩具最终需位于顶行最左侧的格子中。移动序列 RDL 可实现该目标,详见下图以便更直观地理解。另一种可行解是仅按一次按钮 L。

第一个例子中移动操作的示意图。

输入解题思路,AI测评打分。不知道怎么写?

首页