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- ...
随机推荐
- poj Fishnet
http://poj.org/problem?id=1408 #include<cstdio> #include<cstring> #include<cmath> ...
- Delphi图像处理控件
Envision Image Library (Full Sources for D7 to D10-Seattle) v3.08http://www.intervalsoftware.com/env ...
- redis 源码分析
参考: http://redisbook.readthedocs.org/en/latest/index.html http://www.databaseskill.com/3421161/ The ...
- Number of 1 Bits——LeetCode
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also know ...
- Post/Redirect/Get pattern | PRG 模式
Post/Redirect/Get 是一种 web 开发设计模式,用于防止表单的重复提交. 默认情况,提交 Post 请求到服务器后,如果直接刷新浏览器,会重新在提交一次 Post 请求.在访问电商网 ...
- 阳光餐厅--oracle---建表---danrong
select * from manager; select * from dish; select * from board; select * from employee; select * fro ...
- 【科研论文】W5100在远程电力质量监测设备中的应用
摘要: 针对传统电力质量监测方法实时性.多参数测试性能较差的缺点,提出了将以太网接入技术与电能采集相结合进行电力质量现场和远程在线监测的设计方案.硬件设计采用微控制器STM32FI03和以太网控制芯片 ...
- unix网络编程第三版源代码ubuntu下配置的问题解决
第一步:首先下载本书配套的源码unpv13e.tar.gz 第二步:解压后进入根文件夹有一个README 4 Execute the following from the src/ directory ...
- MySQL定时备份之使用Linux下的crontab定时备份实例
这篇文章主要介绍了使用Linux下的crontab进行MySQL定时备份的例子,需要的朋友可以参考下 复制代码代码如下: ##################################### ...
- Injecting and Binding Objects to Spring MVC Controllers--转
I have written two previous posts on how to inject custom, non Spring specific objects into the requ ...