hdu1702 ACboy needs your help again!(栈处理)
ACboy needs your help again!
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 11427 Accepted Submission(s): 5750
he miss his mother very much and is very scare now.You can't image how dark the room he was put into is, so poor :(.
As a smart ACMer, you want to get ACboy out of the monster's labyrinth.But when you arrive at the gate of the maze, the monste say :" I have heard that you are very clever, but if can't solve my problems, you will die with ACboy."
The problems of the monster is shown on the wall:
Each problem's first line is a integer N(the number of commands), and a word "FIFO" or "FILO".(you are very happy because you know "FIFO" stands for "First In First Out", and "FILO" means "First In Last Out").
and the following N lines, each line is "IN M" or "OUT", (M represent a integer).
and the answer of a problem is a passowrd of a door, so if you want to rescue ACboy, answer the problem carefully!
The first line has one integer,represent the number oftest cases.
And the input of each subproblem are described above.
//hdu1702
#include<iostream>
#include<stdio.h>
#include<queue>
#include<string.h>
#include<stack>
using namespace std;
int main()
{
int n,m,k;
char s[],ss[];
cin>>n;
while(n--)
{
cin>>m;
cin>>s;
if(s[]=='F')//队列
{
queue<int>mm;
for(int i=;i<m;i++)
{
cin>>ss;
if(ss[]=='I')
{
cin>>k;
mm.push(k);
}
else
{
if(mm.empty())
cout<<"None"<<endl;
else
{
cout<<mm.front()<<endl;
mm.pop();
}
}
} }
else//栈
{
stack<int>mmm;
for(int i=;i<m;i++)
{
cin>>ss;
if(ss[]=='I')
{
cin>>k;
mmm.push(k);
}
else
{
if(mmm.empty())
cout<<"None"<<endl;
else
{
cout<<mmm.top()<<endl;
mmm.pop();
}
}
}
}
}
return ;
}
hdu1702 ACboy needs your help again!(栈处理)的更多相关文章
- hdu1702 ACboy needs your help again![简单STL 栈 队列]
目录 题目地址 题干 代码和解释 参考 题目地址 hdu1702 题干 代码和解释 本题很简单,只要掌握STL stack和STL vector的语法即可作答.记录本题是为了记录STL vector的 ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
- (hdu step 8.1.1)ACboy needs your help again!(STL中栈和队列的基本使用)
题目: ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- ACboy needs your help again!--hdu1702
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU - 1702 ACboy needs your help again!(栈和队列)
Description ACboy was kidnapped!! he miss his mother very much and is very scare now.You can't image ...
- HDU1702:ACboy needs your help again!
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- 手工数据结构系列-C语言模拟队列和栈 hdu1702
#include <stdio.h> #include <stdlib.h> //================= DATA STRUCTURE ============== ...
- hdoj 1702 ACboy needs your help again!【数组模拟+STL实现】
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- A - ACboy needs your help again!
ACboy was kidnapped!! he miss his mother very much and is very scare now.You can't image how dark th ...
随机推荐
- 执行CUnit测试出错
est/test_fifo.test: error while loading shared libraries: libcunit.so.1: cannot open shared object f ...
- 2、python的print函数格式化输出
1.格式化输出浮点数(float) pi = 3.141592653 print('%10.3f' % pi) #字段宽10,精度3 ,结果 print('%010.3f' % pi) #用0填充 ...
- JS获得css样式即获得元素的计算样式(《Javascript精粹修订版》书摘)
为HTML文档中的元素指定样式可以有3种方法:使用内嵌样式.在页面的head中对Style进行声明以及外部 CSS 文件.元素的视觉效果往往是由上述3种方式的结合或者其中某一种方式来确定的,但是内嵌样 ...
- URL 与 URI
http://localhost:8080/TEST_Servlet/ClientRequest/test?name=wr getRequestURL:http://localhost:8080/TE ...
- 跨域Ajax请求(jQuery JSONP MVC)
通过jQuery的$.ajax方法发送JSONP请求 js代码 <script type="text/javascript"> function jsonptest2( ...
- ubuntu 下python安装及hello world
//@desn:ubuntu 下python安装及hello world //@desn:码字不宜,转载请注明出处 //@author:张慧源 <turing_zhy@163.com> ...
- 【转】Android自定义控件(三)——有弹性的ListView
原文地址:http://blog.csdn.net/a105865708/article/details/17959459 上一次我们试验了有弹性的ScrollView.详情 这一次,我们来试验有弹性 ...
- HBase优化实战
本文来自网易云社区. 背景 Datastream一直以来在使用HBase分流日志,每天的数据量很大,日均大概在80亿条,10TB的数据.对于像Datastream这种数据量巨大.对写入要求非常高,并且 ...
- linux 虚拟机 安装 php-7.0.2
1.安装依赖包 yum -y install libxml2 libxml2-devel openssl openssl-devel libjpeg libjpeg-devel libpng libp ...
- Logic Controller(逻辑控制器)
逻辑控制器主要用来控制采样器的执行顺序,仅对其子节点的逻辑控制器和采样器其作用. 1.Simple Controller(简单控制器) 简单控制器主要用来组织其他逻辑控制器和采样器,提供了一个块的结构 ...