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 ...
随机推荐
- Linux编译提速
一.简介 项目越来越大,重新编译整个项目是一件很费时的事,总结可以帮助提速方法,如下: 1)tmpfs: 解决IO瓶颈,充分利用本机内存资源 2)make -j: 充分利用本机计算资源 3)distc ...
- 数据库连接池DBUtils
安装 pip3 install DBUtils DBUtils是Python的一个用于实现数据库连接池的模块. 此连接池有两种连接模式: 模式一:为每个线程创建一个连接,线程即使调用了close方法, ...
- SpringMVC——映射请求参数
Spring MVC 通过分析处理方法的签名,将 HTTP 请求信息绑定到处理方法的相应人参中. @PathVariable @RequestParam @RequestHeader 等) Sprin ...
- Java学习第六篇:集合类
一.Java集合类框架 Java集合大致可分为Set.List和Map三种体系,其中Set代表无序.不可重复的集合:List代表有序.重复的集合:而Map则代表具有映射关系的集合:从Java5以后,J ...
- 如何创建JUnit
这里拿Dynamic项目来演示,首先创建一个Dynamic项目,起名,点next, 继续点next, 将web.xml文件勾选,finish, 接下来在Java Resources->src下创 ...
- mysql索引及多表查询
注意where,group by ,having,order by, limit 等的顺序. 主表是被绑定的表,子表是添加了外键了的表,注意,在创建表的时候可以添加外键,也可以创建完了以后添加外键. ...
- WINDOWS权限大牛们,请进
大家好, 我遇到一个问题,我的一台windows7去访问另一个电脑的共享,输入账号密码后,老是说密码不正确.而其他电脑去访问共享,密码账号密码后都OK 我想知道原因是什么?
- Activity和Fragment的生命周期
- Linux 命令之chmod
立贴今日吉,不断更新,欢迎斧正,支持为感! 1. chmod --权限控制 chmod [-cfvR] [--help] [--version] mode file... 说明 : Linux/Uni ...
- LSI Storcli 工具使用
查看RAID卡ID 命令功能 查看LSI SAS3108RAID卡的ID. 命令格式 storcli64 show 使用实例 # 查看LSI SAS3108RAID卡的ID. [root@localh ...