codeforces342B
Xenia and Spies
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 ti (steps are numbered from 1) Xenia watches spies numbers li, li + 1, li + 2, ..., ri (1 ≤ li ≤ ri ≤ 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).
Input
The first line contains four integers n, m, s and f (1 ≤ n, m ≤ 105; 1 ≤ s, f ≤ n; s ≠ f; n ≥ 2). Each of the following m lines contains three integers ti, li, ri (1 ≤ ti ≤ 109, 1 ≤ li ≤ ri ≤ n). It is guaranteed that t1 < t2 < t3 < ... < tm.
Output
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.
Examples
3 5 1 3
1 1 2
2 2 3
3 3 3
4 1 1
10 1 3
XXRR sol:题意很鬼畜,看了半天都没懂
题意:给定 n 个间谍,m个区间,一个 s,一个f,然后从 s开始传纸条,然后传到 f,
然后在每个 t 时间在区间内的不能传,问你最少的时间传过去。
然后直接暴力模拟即可
/*
题意:给定 n 个间谍,m个区间,一个 s,一个f,然后从 s开始传纸条,然后传到 f,
然后在每个 t 时间在区间内的不能传,问你最少的时间传过去。
*/
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
int n,m,Sta,End;
struct Not
{
int Time,l,r;
inline bool operator<(const Not &tmp)const
{
return Time<tmp.Time;
}
}a[N];
int main()
{
int i,opt,Time=,Now=;
R(n); R(m); R(Sta); R(End);
opt=(Sta<End)?:-;
for(i=;i<=m;i++)
{
R(a[i].Time); R(a[i].l); R(a[i].r);
}
sort(a+,a+m+);
while(Sta!=End)
{
if(a[Now].Time==Time)
{
int Weiz=Sta+opt;
bool Flag=;
while(a[Now].Time==Time&&Now<=m)
{
if((Weiz>=a[Now].l&&Weiz<=a[Now].r)||(Sta>=a[Now].l&&Sta<=a[Now].r)) Flag=;
Now++;
}
if(Flag) putchar('X');
else
{
(opt==)?putchar('R'):putchar('L'); Sta+=opt;
}
}
else
{
(opt==)?putchar('R'):putchar('L'); Sta+=opt;
}
Time++;
}
return ;
}
/*
Input
3 5 1 3
1 1 2
2 2 3
3 3 3
4 1 1
10 1 3
Output
XXRR Input
5 11 1 5
1 1 5
2 2 2
3 1 1
4 3 3
5 3 3
6 1 1
7 4 4
8 4 5
10 1 3
11 5 5
13 1 5
Output
XXXRXRXXRR
*/
codeforces342B的更多相关文章
随机推荐
- Asp.Net Core 轻松学-实现跨平台的自定义Json数据包
前言 在前后端分离的业务开发中,我们总是需要返回各种各样的数据包格式,一个良好的 json 格式数据包是我们一贯奉行的原则,下面就利用 Json.Net 来做一个简单具有跨平台的序列化数据包实 ...
- .Net Core Web Api 上传女朋友的照片到微软云Azure Storage
前言 实现一个Web Api,把女朋友照片保存到Azure云的storage里. Image Upload Api 在对应的Api Controller里,加上attribute: [Consumes ...
- SLAM+语音机器人DIY系列:(三)感知与大脑——3.轮式里程计与运动控制
摘要 在我的想象中机器人首先应该能自由的走来走去,然后应该能流利的与主人对话.朝着这个理想,我准备设计一个能自由行走,并且可以与人语音对话的机器人.实现的关键是让机器人能通过传感器感知周围环境,并通过 ...
- 使用Atlas进行元数据管理之容错和高可用
1. 介绍 Apache Atlas使用各种系统并与之交互,为数据管理员提供元数据管理和数据血缘信息.通过适当地选择和配置这些依赖关系,可以使用Atlas实现高度的服务可用性.本文档介绍了Atlas中 ...
- DS控件库 在Combobox中嵌入远程桌面
本示例演示DS开放式下拉列表控件中加入一个RDP远程桌面控件. 先在VS工具箱中添加COM控件Microsoft RDP Client Control,后面的Version版本可以适当高点. 然后将R ...
- 解决Win10系统下 C# DateTime 出现星期几的问题
昨天晚上写代码的时候偶然发现 DateTime 里出现了星期几,当时一阵凌乱,去网上百度没有详细解决办法,很多人说可以用用 ToString 解决. 也有部分人说可以修改系统时间的显示,我打算试一下看 ...
- Java面试 32个核心必考点完全解析
目录 课程预习 1.1 课程内容分为三个模块 1.2 换工作面临问题 1.3 课程特色 课时1:技术人职业发展路径 1.1 工程师发展路径 1.2 常见技术岗位划分 1.3 面试岗位选择 1.4 常见 ...
- SpringBoot JPA(实现查询多值)
JPA是java Persistence API简称,中文名:java持久层API,JPA是JCP组织发布的J2EE标准之一 1.创建DataSource连接池对象 <dependency> ...
- Javascript之高级数组API的使用实例
JS代码中我们可以根据需求新建新的对象解决问题的同时,也有一些常用的内置对象供我们使用,我们称之为API,本篇文章只是对数组部分进行了练习. 例一:伪数组,不能修改长短的数组(所以没办法清零),可以修 ...
- SQL Server数据仓库的基础架构规划
问题 SQL Server数据仓库具有自己的特征和行为属性,有别去其他.从这个意义上说,数据仓库基础架构规划需要与标准SQL Server OLTP数据库系统的规划不同.在本文中,我们将介绍在计划数据 ...