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 ...
随机推荐
- Browsersync 简介 and 使用
简介 省时的浏览器同步测试工具,Browsersync能让浏览器实时.快速响应您的文件更改(html.js.css.sass.less等)并自动刷新页面. 曾经我们每改一次的代码,都需要手动去刷新一次 ...
- HttpSession相关API
//获取Session对象 request.getSession() request.getSession(boolean create) //获取SessionId getId() //获取当前se ...
- qt-vs-addin:Qt4和Qt5之VS插件如何共存与使用(转)
原则上,两者是不可以同时存在的,但是如果都安装了,该如何分别使用他们呢? Qt4 Visual Studio Add-in:官网可以下载安装程序,qt-vs-addin-1.1.11-opensour ...
- (转)XSS危害——session劫持
原文地址:http://www.cnblogs.com/dolphinX/p/3403027.html 在跨站脚本攻击XSS中简单介绍了XSS的原理及一个利用XSS盗取存在cookie中用户名和密码的 ...
- sql 与 oracle 几个简单语法差别
sql 与 oracle 之间的 语法差别. 简单的几个函数转换 sql-> Up_Time=getdate(), isnull(), substring(), charindex(), ...
- .net 3.5 Lambda表达式
Lambda表达式 转自http://www.cnblogs.com/kingmoon/archive/2011/05/03/2035696.html "Lambda表达式"是一个 ...
- C# File类常用方法
File 类 提供用于创建.复制.删除.移动和打开文件的静态方法,并协助创建 FileStream 对象. 1. File.Exists —— 确定指定的文件是否存在. public static ...
- SQL/T-SQL实例参考-2
对多关联查询,查询多中的记录,但是返回一的结果集 子查询语法 --一对多关联查询,查询多中的记录,但是返回一的结果集 SELECT C.* FROM ( SELECT A.BasicID FROM [ ...
- Promise超时情况
export const ERROR_PROMISE_TIMEOUT = 'ERROR_PROMISE_TIMEOUT'; export default function (promise, time ...
- spring (1)
相关名词: 控制反转(IoC):将对象的创建交由spring创建,1创建新class,2xml中配置 3测试context.getBean("") 类似对象工厂(工厂模式)-xml ...