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的更多相关文章
随机推荐
- java内存溢出的情况解决方法
内存溢出虽然很棘手,但也有相应的解决办法,可以按照从易到难,一步步的解决. 第一步,就是修改JVM启动参数,直接增加内存.这一点看上去似乎很简单,但很容易被忽略.JVM默认可以使用的内存为64M,To ...
- JVM(六)为什么新生代有两个Survivor分区?
本文会使用排除法的手段,来讲解新生代的区域划分,从而让读者能够更清晰的理解分代回收器的原理,在开始之前我们先来整体认识一下分代收集器. 分代收集器会把内存空间分为:老生代和新生代两个区域,而新生代又会 ...
- DSAPI 短域名服务
有时,需要将长域名转换为短域名,或是为了减少字符量,或是为了隐藏真实网址.在DSAPI中,集成了EPS-GS的短域名接口.该功能需要联接互联网,从EPS服务器获取. 代码 DSAPI.网络.短域名服务 ...
- aspx中的checkbox 取值问题
问题:前台checkbox控件,选中值为1,不选值为0: 解决方案: 插入一行 <input type="hidden" name="RemberPwd" ...
- 学JAVA第十三天,方法、方法重载及构造函数
今天终于不讲狗跳楼的问题了,今天讲了方法,方法重载及构造函数及构造函数重载的课程了. 这里说了有参好无参的,下面讲构造函数重载和方法重载. 其实,这上面写的这些方法,就相当一个模板.想要快速做出产品就 ...
- 结合JDK源码看设计模式——策略模式
前言: 现在电商已经成为我们生活中不可或缺的购物渠道,同时各大商家会针对不同的时间做出不同的折扣,这在我们看来就是一种营销手段,也是一种策略,今天我们就来讲讲JDK中的策略模式是怎么样的. 一.定义 ...
- Poj1799
Yeehaa! Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 15082 Accepted: 6675 Descript ...
- vue学习之vuex
1 首先还是安装 npm install vuex --save. 2 在src这种创建目录为store 创建 index.js (getters.js ,actions.js ,mutation ...
- 用app.net Core搞掂多国语言网站
Asp.net Core 中文文档很少,你可以看英文的,不过英文的也是说的有点乱.这篇文章是干货. 1. 配置好你的WebApplication,使他可以支持国际化语言,修改文档Startup.cs ...
- 深圳市共创力咨询CEO杨学明的最新演讲:互联网模式下的企业创新管理
2018年11月14日, 深圳市共创力咨询董事长.深圳市汇成研发管理咨询公司董事长杨学明先生受邀参加由深圳图书馆主办,深圳手讯视频承办的“倾听行业之声”2018第二届世界CED智慧大会,此次分享的主题 ...