A9964 | Berserk Robot
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Help! A robot escaped our lab and we need help finding it.
The lab is at the point $(0,0)$ of the coordinate plane, at time 0 the robot was there. The robot's movements are defined by a program — a string of length $l$ , consisting of characters U, L, D, R. Each second the robot executes the next command in his program: if the current coordinates of the robot are $(x,y)$ , then commands U, L, D, R move it to cells $(x,y+1)$ , $(x-1,y)$ , $(x,y-1)$ , $(x+1,y)$ respectively. The execution of the program started at time 0. The program is looped, i.e. each $l$ seconds of executing the program start again from the first character. Unfortunately, we don't know what program was loaded into the robot when he left the lab.
Our radars managed to find out the position of the robot at $n$ moments of time: we know that at the moment of time $t_{i}$ the robot is at the point $(x_{i},y_{i})$ . Given this data, either help to determine what program could be loaded into the robot, or determine that no possible program meets the data and the robot must have broken down.
The lab is at the point $(0,0)$ of the coordinate plane, at time 0 the robot was there. The robot's movements are defined by a program — a string of length $l$ , consisting of characters U, L, D, R. Each second the robot executes the next command in his program: if the current coordinates of the robot are $(x,y)$ , then commands U, L, D, R move it to cells $(x,y+1)$ , $(x-1,y)$ , $(x,y-1)$ , $(x+1,y)$ respectively. The execution of the program started at time 0. The program is looped, i.e. each $l$ seconds of executing the program start again from the first character. Unfortunately, we don't know what program was loaded into the robot when he left the lab.
Our radars managed to find out the position of the robot at $n$ moments of time: we know that at the moment of time $t_{i}$ the robot is at the point $(x_{i},y_{i})$ . Given this data, either help to determine what program could be loaded into the robot, or determine that no possible program meets the data and the robot must have broken down.
输入格式
The first line of the input contains two space-separated integers $n$ and $l$ ( $1<=n<=2·10^{5}$ , $1<=l<=2·10^{6}$ ).
Next $n$ lines contain three space-separated integers — $t_{i}$ , $x_{i}$ , $y_{i}$ ( $1<=t_{i}<=10^{18}$ , $-10^{18}<=x_{i},y_{i}<=10^{18}$ ). The radar data is given chronologically, i.e. $t_{i}<t_{i+1}$ for all $i$ from 1 to $n-1$ .
Next $n$ lines contain three space-separated integers — $t_{i}$ , $x_{i}$ , $y_{i}$ ( $1<=t_{i}<=10^{18}$ , $-10^{18}<=x_{i},y_{i}<=10^{18}$ ). The radar data is given chronologically, i.e. $t_{i}<t_{i+1}$ for all $i$ from 1 to $n-1$ .
输出格式
Print any of the possible programs that meet the data. If no program meets the data, print a single word 'NO' (without the quotes).
输入输出样例
输入 #1
3 3 1 1 0 2 1 -1 3 0 -1
输出 #1
RDL
输入 #2
2 2 1 1 0 999 1 0
输出 #2
RL
输入 #3
2 5 10 10 0 20 0 0
输出 #3
NO
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted