uva 12207 - That is Your Queue
2024-08-27 03:52:29
#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).没看到这一条件,不仔细;
最新文章
- How to add taxonomy element to a summary view?
- C++ compile issue
- BZOJ4552: [Tjoi2016&;Heoi2016]排序
- [原创]使用Pandoc实现Markdown文件转PDF文件
- ubuntu下常用服务器的构建
- MySQL修改root密码的各种方法整理
- Code First 约定
- poj1472[模拟题]
- C++程序设计实践指导1.3求任意整数降序数改写要求实现
- 【原创】纯OO:从设计到编码写一个FlappyBird (五)
- Python CSV 超简明用法
- 纯css3打造瀑布流布局
- ●BZOJ 1185 [HNOI2007]最小矩形覆盖
- AJAX跨域请求详解
- SpringBoot系列——快速构建项目
- C++成员函数在内存中的存储方式
- UVALive - 6440(模拟)
- XML 试题
- 补课:Shell命令${}
- TCP/UDP区别&;&;心跳包机制【转】