301809: CF342B. Xenia and Spies

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Xenia and Spies

题意翻译

有n个人站在一条线上,先要将一个东西从从s人手里传到f人手里,每一秒可以传给相邻的一个人,在t[i]时间,有from[i]到to[i]区间内的人会被监视,被监视的人不能传递和接受东西,在第t[i]秒时,手上握有纸条的人,可以选择不传或者往左往右传,请问要怎么传才可以最快将纸条从第s个人传到第f个人手上。

题目描述

Xenia the vigorous detective faced $ n $ $ (n>=2) $ foreign spies lined up in a row. We'll consider the spies numbered from 1 to $ n $ from left to right. Spy $ s $ has an important note. He has to pass the note to spy $ f $ . Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the note to one of his neighbours in the row. In other words, if this spy's number is $ x $ , he can pass the note to another spy, either $ x-1 $ or $ x+1 $ (if $ x=1 $ or $ x=n $ , then the spy has only one neighbour). Also during a step the spy can keep a note and not pass it to anyone. But nothing is that easy. During $ m $ steps Xenia watches some spies attentively. Specifically, during step $ t_{i} $ (steps are numbered from 1) Xenia watches spies numbers $ l_{i},l_{i}+1,l_{i}+2,...,r_{i} $ $ (1<=l_{i}<=r_{i}<=n) $ . Of course, if during some step a spy is watched, he can't do anything: neither give the note nor take it from some other spy. Otherwise, Xenia reveals the spies' cunning plot. Nevertheless, if the spy at the current step keeps the note, Xenia sees nothing suspicious even if she watches him. You've got $ s $ and $ f $ . Also, you have the steps during which Xenia watches spies and which spies she is going to watch during each step. Find the best way the spies should act in order to pass the note from spy $ s $ to spy $ f $ as quickly as possible (in the minimum number of steps).

输入输出格式

输入格式


The first line contains four integers $ n $ , $ m $ , $ s $ and $ f $ $ (1<=n,m<=10^{5}; 1<=s,f<=n; s≠f; n>=2) $ . Each of the following $ m $ lines contains three integers $ t_{i},l_{i},r_{i} $ $ (1<=t_{i}<=10^{9},1<=l_{i}<=r_{i}<=n) $ . It is guaranteed that $ t_{1}&lt;t_{2}&lt;t_{3}&lt;...&lt;t_{m} $ .

输出格式


Print $ k $ characters in a line: the $ i $ -th character in the line must represent the spies' actions on step $ i $ . If on step $ i $ the spy with the note must pass the note to the spy with a lesser number, the $ i $ -th character should equal "L". If on step $ i $ the spy with the note must pass it to the spy with a larger number, the $ i $ -th character must equal "R". If the spy must keep the note at the $ i $ -th step, the $ i $ -th character must equal "X". As a result of applying the printed sequence of actions spy $ s $ must pass the note to spy $ f $ . The number of printed characters $ k $ must be as small as possible. Xenia must not catch the spies passing the note. If there are miltiple optimal solutions, you can print any of them. It is guaranteed that the answer exists.

输入输出样例

输入样例 #1

3 5 1 3
1 1 2
2 2 3
3 3 3
4 1 1
10 1 3

输出样例 #1

XXRR

Input

题意翻译

有n个人站在一条线上,先要将一个东西从从s人手里传到f人手里,每一秒可以传给相邻的一个人,在t[i]时间,有from[i]到to[i]区间内的人会被监视,被监视的人不能传递和接受东西,在第t[i]秒时,手上握有纸条的人,可以选择不传或者往左往右传,请问要怎么传才可以最快将纸条从第s个人传到第f个人手上。

加入题单

上一题 下一题 算法标签: