302781: CF538G. Berserk Robot
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Berserk Robot
题意翻译
有一个机器人,第 $0$ 秒时在 $(0,0)$ 位置。 机器人会循环执行一个长度为 $l$ 的指令序列,每秒执行一个指令。 指令有 `ULDR` 四种,分别代表向上/左/下/右移动一格。 你不知道这个指令序列具体是什么,但是你知道 $n$ 条信息,第 $i$ 条信息为「第 $t_i$ 秒时机器人在 $(x_i,y_i)$」,保证 $t$ 递增。 你需要构造一个满足这些信息的指令序列,或判断不存在。 $n \le 2 \times 10^5$,$l \le 2 \times 10^6$,$t_i,|x_i|,|y_i| \le 10^{18}$。题目描述
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 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 $ .
输出格式
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