queue的使用-Hdu 1702
ACboy needs your help again!
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 16823 Accepted Submission(s): 8254
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.
#include <iostream>
#include <queue>
#include <stack>
#include <string> using namespace std; int main()
{
int t,n,temp;
cin>>t;
while(t--){
string str,str1;
queue<int>Q;
stack<int>S;
cin>>n>>str;
for(int i = ;i < n; i++){
if(str=="FIFO"){
cin>>str1;
if(str1=="IN"){
cin>>temp;
Q.push(temp);
}
if(str1=="OUT"){
if(Q.empty())
cout<<"None"<<endl;
else{
cout<<Q.front()<<endl;
Q.pop();
}
}
}
else{
cin>>str1;
if(str1=="IN"){
cin>>temp;
S.push(temp);
}
if(str1=="OUT"){
if(S.empty())
cout<<"None"<<endl;
else{
cout<<S.top()<<endl;
S.pop();
}
}
}
}
}
return ;
}
queue的使用-Hdu 1702的更多相关文章
- hdu 1702 ACboy needs your help again!
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1702 ACboy needs your help again! Description ACboy w ...
- 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 ...
- HDU 1702 http://acm.hdu.edu.cn/showproblem.php?pid=1702
#include<stdio.h> #include<string.h> #include<queue> #include<stack> #define ...
- HDU 1702 队列与栈的简单运用http://acm.hdu.edu.cn/showproblem.php?pid=1702
#include<stdio.h> #include<string.h> #include<queue> #include<stack> #define ...
- hdu 1702 栈和队列的简单应用
#include<stdio.h> #include<string.h> #include<queue> #include<stack> using n ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
- 第一周训练 | STL和基本数据结构
A - 圆桌问题: HDU - 4841 #include<iostream> #include<vector> #include<stdio.h> #includ ...
- hdu 栈题1022&1702
http://acm.hdu.edu.cn/showproblem.php?pid=1022 http://blog.csdn.net/swm8023/article/details/6902426此 ...
- hdu 1387(Team Queue) STL
Team Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
随机推荐
- jave的安装
1.此电脑-属性-高级系统设置-环境变量2.点下面那个 新建- JAVA_HOME3. 双击PATH变量,新建一个参数 4.新建CLASSPATH环境变量
- rest_framework:版本控制
一.作用: 用于版本的控制,区分不同的功能,对于一些新增功能的添加更新就会在新的版本中体现,有点类似于,新版本就是软件发布的新版本,和老版本相比新增或者修改了一些功能 二.内置的版本控制类: from ...
- windows redis启动
1.下载redis 2.启动redis 3.启动redis客户端并设置protected-mode为false
- 汉语诗词 LaTeX 排版样式
清世何须忧庙廊——汉语诗词 LaTeX 排版样式 作者想一些中国古典诗歌,发现大多数早期的例子都是为了英文诗而创作的环境. 下面是作者给出唐诗选集的布局实例. 它不是一般解决方案,而只是一个特定的例子 ...
- AST抽象语法树——最基础的javascript重点知识,99%的人根本不了解
AST抽象语法树——最基础的javascript重点知识,99%的人根本不了解 javascriptvue-clicommonjswebpackast 阅读约 27 分钟 抽象语法树(AST),是一 ...
- android 获取webview内容真实高度(webview上下可滚动距离)
正常获取: mainWebView.getContentHeight()//获取html高度 mainWebView.getScale()//手机上网页缩放比例 mainWebView.getHeig ...
- Java-POJ1003-Hangover
题目大意: 给出一个浮点数a,求出使得 不等式 1/2 + 1/3 + ... + 1/(n+1) ≥ a 成立的最小值 大水题,由于数据范围小,给出了确认上界5.20,满足二分答案 但是我懒啊,直接 ...
- apache http server 和tomcat的区别 以及nginx
Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器. 要明白他们之间的区别,我们首先需要明白HTTP协议.HTML页面.JSP.Servlet之 ...
- java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
运行项目时出现java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException时,只 ...
- Ehab and a Special Coloring Problem
You're given an integer nn. For every integer ii from 22 to nn, assign a positive integer aiai such ...