CF79E.Security System

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Fox Ciel safely returned to her castle, but there was something wrong with the security system of the castle: sensors attached in the castle were covering her.

Ciel is at point (1, 1) of the castle now, and wants to move to point (n, n), which is the position of her room. By one step, Ciel can move from point (x, y) to either (x + 1, y) (rightward) or (x, y + 1) (upward).

In her castle, _c_2 sensors are set at points (a + i, b + j) (for every integer i and j such that: 0 ≤ i < c, 0 ≤ j < c).

Each sensor has a count value and decreases its count value every time Ciel moves. Initially, the count value of each sensor is t. Every time Ciel moves to point (x, y), the count value of a sensor at point (u, v) decreases by (|u - x| + |v - y|). When the count value of some sensor becomes strictly less than 0, the sensor will catch Ciel as a suspicious individual!

Determine whether Ciel can move from (1, 1) to (n, n) without being caught by a sensor, and if it is possible, output her steps. Assume that Ciel can move to every point even if there is a censor on the point.

小狐狸Ciel安全返回了她的城堡,但城堡的安全系统却出了问题:安装在城堡中的传感器正在监视她。

Ciel当前位于城堡的点 (1, 1)(1,\,1),她希望移动到点 (n, n)(n,\,n)(即她的房间所在位置)。每一步,Ciel可以从点 (x, y)(x,\,y) 移动到 (x+1, y)(x+1,\,y)(向右)或 (x, y+1)(x,\,y+1)(向上)。

在她的城堡中,共设置了 c2c^2 个传感器,位置为 (a+i, b+j)(a+i,\,b+j)(对所有满足 0≤i<c0\le i<c 且 0≤j<c0\le j<c 的整数 ii 和 jj)。

每个传感器都有一个计数值,每当Ciel移动时,该计数值就会减少。初始时,每个传感器的计数值均为 tt。每当Ciel移动到点 (x, y)(x,\,y) 时,位于点 (u, v)(u,\,v) 的传感器的计数值将减少 ∣u−x∣+∣v−y∣|u-x|+|v-y|。若某个传感器的计数值严格小于 0,则该传感器会立即将Ciel识别为可疑人员并将其捕获!

请判断Ciel能否在不被任何传感器捕获的前提下,从 (1, 1)(1,\,1) 移动到 (n, n)(n,\,n);若可以,请输出她的移动路径。注意:即使某点上存在传感器,Ciel仍可自由经过该点。

输入格式

In the first line there are five integers n, t, a, b, c (2 ≤ n ≤ 2·105,  0 ≤ t ≤ 1014,  1 ≤ a ≤ n - c + 1,  1 ≤ b ≤ n - c + 1,  1 ≤ c ≤ n).

Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin stream (also you may use the %I64d specificator).

第一行包含五个整数 nn、tt、aa、bb、cc(满足 2≤n≤2⋅1052 \leq n \leq 2 \cdot 10^5,0≤t≤10140 \leq t \leq 10^{14},1≤a≤n−c+11 \leq a \leq n - c + 1,1≤b≤n−c+11 \leq b \leq n - c + 1,1≤c≤n1 \leq c \leq n)。

在 C++ 中,请勿使用 %lld 格式说明符读取或写入 64 位整数。推荐使用 cin 流(也可使用 %I64d 格式说明符)。

输出格式

If Ciel's objective is possible, output in first line 2_n_ - 2 characters that represent her feasible steps, where i-th character is R if i-th step is moving rightward, or U if moving upward. If there are several solution, output lexicographically first one. Character R is lexicographically earlier than the character U.

If her objective is impossible, output Impossible.

如果青空的目标可以实现,则在第一行输出一个长度为 2n−22n-2 的字符串,表示她可行的移动步骤;其中第 ii 个字符为 R 表示第 ii 步向右移动,为 U 表示向上移动。若存在多个解,输出字典序最小的一个(字符 R 的字典序早于 U)。

若她的目标无法实现,则输出 Impossible。

输入输出样例

  • 输入#1

    5 25 2 4 1

    输出#1

    RRUURURU
  • 输入#2

    3 6 1 2 2

    输出#2

    URUR
  • 输入#3

    3 5 1 2 2

    输出#3

    Impossible
  • 输入#4

    20 492 11 4 8

    输出#4

    RRRRRRRRRRRRRRRRUUUUURUUUUURRUUUUUUUUU

说明/提示

The answers for the first sample and the second sample are shown on the picture:

Here, a red point represents a point that contains a sensor.

第一个样例和第二个样例的答案如图所示:

其中,红点表示安装有传感器的点。

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

首页