codeforces B. Xenia and Spies 解题报告
题目链接:http://codeforces.com/problemset/problem/342/B
题目意思:有n个spy,编号从1~n,从左到右排列。现在的任务是,spy s要把信息传递到spy f,但必须要满足:当spy li ~ spy ri 被观看时,这一段spy不能传递信息。
要注意的是,step数(也就是ti)不一定是按顺序排列下来的,它有可能与上一行的step相差好几轮。此时,这好几轮中,spy s 是可以继续往spy f的方向传递信息的,直到移动完这好几轮的数目为止。除此,有可能m未完全输出完,spy s已经把信息传到spy f 中了;还有编号为 s 的spy编号有可能比spy f的编号小, 这些都是需要考虑的。
模拟题,考的就是细心,还有考虑周全!!!
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std; int main()
{
int n, m, s, f;
while (scanf("%d%d%d%d", &n, &m, &s, &f) != EOF)
{
int move = (s > f ? - : ); // 记录是往左移还是往右移
int current, l, r;
int next = ; // next的设置很重要,它关乎到当前step和上一行的step间隔多少来处理消息的移动
current = ;
while (s != f)
{
if (current < next && m > )
{
scanf("%d%d%d", ¤t, &l, &r);
m--;
}
if (current == next && ((s >= l && s <= r) || s + move >= l && s + move <= r)) // "||"后面的条件容易遗忘,它表示当移动一步后是否处于被看的序列中,如果是则不能移动
printf("X");
else
{
printf("%c", s > f ? 'L' : 'R');
s += move;
// printf("s = %d\n", s);
}
next++;
// printf("\ncurrent = %d, next = %d\n", current, next);
}
while (m--) // 未到达m行,消息已经成功传递到spy f中,此时要继续执行到m行为止
scanf("%d%d%d", ¤t, &l, &r);
printf("\n");
}
return ;
}
codeforces B. Xenia and Spies 解题报告的更多相关文章
- codeforces B. Xenia and Ringroad 解题报告
题目链接:http://codeforces.com/problemset/problem/339/B 题目理解不难,这句是解题的关键 In order to complete the i-th ta ...
- codeforces A. Xenia and Divisors 解题报告
题目链接:http://codeforces.com/problemset/problem/342/A 题目意思:给出n个数,找出n/3个组且每组有3个数,这三个数必须要符合两个条件:1.a < ...
- Codeforces Educational Round 92 赛后解题报告(A-G)
Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...
- codeforces 476C.Dreamoon and Sums 解题报告
题目链接:http://codeforces.com/problemset/problem/476/C 题目意思:给出两个数:a 和 b,要求算出 (x/b) / (x%b) == k,其中 k 的取 ...
- Codeforces Round #382 (Div. 2) 解题报告
CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...
- codeforces 507B. Amr and Pins 解题报告
题目链接:http://codeforces.com/problemset/problem/507/B 题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置.问最少步数是多少.移动见下图.( ...
- codeforces 500B.New Year Permutation 解题报告
题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...
- codeforces 462C Appleman and Toastman 解题报告
题目链接:http://codeforces.com/problemset/problem/461/A 题目意思:给出一群由 n 个数组成的集合你,依次循环执行两种操作: (1)每次Toastman得 ...
- codeforces 460A Vasya and Socks 解题报告
题目链接:http://codeforces.com/problemset/problem/460/A 题目意思:有一个人有 n 对袜子,每天早上会穿一对,然后当天的晚上就会扔掉,不过他会在 m 的倍 ...
随机推荐
- 求第N数大问题
问题: InputThe first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of ...
- POJ1995 Raising Modulo Numbers
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6373 Accepted: ...
- Linux Kernel sys_call_table、Kernel Symbols Export Table Generation Principle、Difference Between System Calls Entrance In 32bit、64bit Linux
目录 . sys_call_table:系统调用表 . 内核符号导出表:Kernel-Symbol-Table . Linux 32bit.64bit环境下系统调用入口的异同 . Linux 32bi ...
- Linux Systemcall By INT 0x80、Llinux Kernel Debug Based On Sourcecode
目录 . 系统调用简介 . 系统调用跟踪调试 . 系统调用内核源码分析 1. 系统调用简介 关于系统调用的基本原理,请参阅另一篇文章,本文的主要目标是从内核源代码的角度来学习一下系统调用在底层的内核中 ...
- Recon-Erlang线上系统诊断工具
Erlang系统素以稳定可靠闻名,但是它也是c实现的,也是要管理比如内存,锁等等复杂的事情,也会出现Crash,而且crash的时候大部分原因是因为内存问题.为此erlang运行期提供了强大的自省机制 ...
- p2p软件如何穿透内网进行通信
http://blog.chinaunix.net/uid-22326462-id-1775108.html 首先先介绍一些基本概念: NAT(Network Address Translators) ...
- EJB3 QL查询
http://www.blogjava.net/liaojiyong/archive/2008/07/11/56216.html EJB3 QL查询 EJB3的查询语言是一种和SQL非常类似的中间性和 ...
- UVA1025---A Spy in the Metro(DP)
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35913 Secret agent Maria was sent to Alg ...
- linux下的三种解压文件的命令?
那要看你的压缩文件使用哪种压缩方式:gzip,压缩文件名:zip或gz,解压命令:unzipbzip2,压缩文件名:bz,解压命令:bzip2 -d上面两个是最常用的压缩方式,一般在linux下可以通 ...
- 修复VirtualBox "This kernel requires the following features not present on the CPU: pae Unable to boot
问题描述: 1.机器:Linux主机,特别是主机为大内存,比如: 4G内存的使用pae内核的Ubuntu系统的dell电脑. 2.情况:使用VirtualBox安装Linux系统时,比如:通过Virt ...