uva 12207 - That is Your Queue
#include <cstdio>
#include <iostream>
#include <deque>
using namespace std; int main()
{
deque<long> cir;
long P, C, cas = ; while(scanf("%ld%ld", &P, &C) && P)
{
cir.clear();
for (int i = ; i <= P && i <= ; i++) // 1 ≤ C ≤ 1000
cir.push_back(i); printf("Case %ld:\n", ++cas); while(C--)
{
char c;
getchar();
scanf("%c", &c); if(c == 'N')
{
long tempN = cir.front();
cir.pop_front();
cir.push_back(tempN);
cout << tempN << endl;
}else if(c == 'E')
{
long x;
scanf("%ld", &x);
for(deque<long>::iterator it = cir.begin(); it != cir.end(); ++ it)
if(*it == x)
{
cir.erase(it);
break;
}
cir.push_front(x);
}
}
}
return ;
}
Time limit exceeded的原因:and C, the number of commands to process (1 ≤ C ≤ 1000).没看到这一条件,不仔细;
uva 12207 - That is Your Queue的更多相关文章
- UVa 540 (团体队列) Team Queue
题意: 每个人都属于一个团体,在排队的时候,如果他所在的团体有人在队伍中,则他会站到这个团体的最后.否则站到整个队伍的队尾. 输出每次出队的人的编号. 分析: 容易看出,长队中,在同一个团体的人是排在 ...
- uva 10935 throwing cards away <queue>
Given is an ordered deck of n cards numbered 1 to n with card 1 at the top and card n ...
- 【例题4-3 uva 133】The Dole Queue
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 写个数组模拟链表 但注意,得用个辅助数组flag.. 不然可能会出现没能跳过中间的被占区域的情况. 比如 1 2 idx # # # ...
- (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO
http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...
- ACM训练计划step 1 [非原创]
(Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...
- 算法竞赛入门经典+挑战编程+USACO
下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...
- UVA.540 Team Queue (队列)
UVA.540 Team Queue (队列) 题意分析 有t个团队正在排队,每次来一个新人的时候,他可以插入到他最后一个队友的身后,如果没有他的队友,那么他只能插入到队伍的最后.题目中包含以下操作: ...
- uva 540 - Team Queue(插队队列)
首发:https://mp.csdn.net/mdeditor/80294426 例题5-6 团体队列(Team Queue,UVa540) 有t个团队的人正在排一个长队.每次新来一个人时,如果他有队 ...
- Trees on the level UVA - 122 复习二叉树建立过程,bfs,queue,strchr,sscanf的使用。
Trees are fundamental in many branches of computer science (Pun definitely intended). Current state- ...
随机推荐
- 简单又强大的联发科手机PhilZ Touch Recovery安装器,详细教程 - 本文出自高州吧
原文地址:http://bbs.gaozhouba.com/thread-19355-1-1.html * * * * * * * * * * * * * * * * * * * * * * * * ...
- 转:Node.js异步处理CPU密集型任务的新思路
原文来自于:http://www.infoq.com/cn/articles/new-idea-of-nodejs-asynchronous-processing-tasks?utm_source=i ...
- SPSS相关和回归分析
1.语文和数学成绩都受IQ的影响而且相互影响,则分析语文和数学的关系时需要偏相关分析.2.距离分析用于探索相似性,比如给了某年的12个月三个城市的气温数据,然后分析,会得到一个相似性矩阵,这是个对称阵 ...
- poj 3592 Instantaneous Transference
http://poj.org/problem?id=3592 #include <cstdio> #include <cstring> #include <algorit ...
- Chrome不支持NPAPI的信息与替代方案
昨天Chrome稳定版更新到了42版,发现百度云.支付宝.网银等等的插件都失效了,打开 chrome://plugins/ 一看,NPAPI都消失了,只有flash的插件还在.解决办法是到 chrom ...
- eclipse能够自动提示变量名.
打开 Eclipse -> Window -> Perferences -> Java -> Editor -> Content Assist,在右边最下面一栏找到 au ...
- BZOJ 1037 [ZJOI2008]生日聚会Party
1037: [ZJOI2008]生日聚会Party Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1583 Solved: 936[Submit][ ...
- 深入JS系列学习3
深入JS系列学习3 深入理解JavaScript系列(9):根本没有"JSON对象"这回事! 很多JavaScript开发人员都错误地把JavaScript对象字面量(Object ...
- 挂载nfs系统问题之: Root-NFS: Server returned error -13 while mounting
今天换了个路由器,由于是自动分的IP,现在的IP和之前的不在同一网段.以前是192.168.0.xxx,现在是192.168.1.xxx.本以为将serverip,ipaddr,bootargs这些参 ...
- [Java Concurrent] 多线程合作 producer-consumers / queue 的简单案例
在多线程环境下,通过 BlockingQueue,实现生产者-消费者场景. Toast 被生产和消费的对象. ToastQueue 继承了 LinkedblockingQueue ,用于中间存储 To ...