队列和栈的判空都可以用empty

#include <bits/stdc++.h>
using namespace std; string oper,stru;
int T,M,num; int main()
{
cin>>T;
while (T--) {
cin>>M>>stru;
if (stru=="FIFO") {
queue<int>q;
for (int i=0;i<M;i++) {
cin>>oper;
if (oper=="IN") {
cin>>num;
q.push(num);
}
else {
if (!q.empty()) {
cout<<q.front()<<endl;
q.pop();
}
else {
cout<<"None"<<endl;
}
}
}
}
else {
stack<int>s;
for (int i=0;i<M;i++) {
cin>>oper;
if (oper=="IN") {
cin>>num;
s.push(num);
}
else {
if (!s.empty()) {
cout<<s.top()<<endl;
s.pop();
}
else {
cout<<"None"<<endl;
}
}
}
}
}
return 0;
}

HDU-1702-ACboy needs your help again!(Stack)的更多相关文章

  1. hdu 1702 ACboy needs your help again!

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1702 ACboy needs your help again! Description ACboy w ...

  2. 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 ...

  3. HDU 1712 ACboy needs your help(包背包)

    HDU 1712 ACboy needs your help(包背包) pid=1712">http://acm.hdu.edu.cn/showproblem.php? pid=171 ...

  4. HDU 1712 ACboy needs your help (分组背包模版题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 有n门课,和m天时间.每门课上不同的天数有不同的价值,但是上过这门课后不能再上了,求m天里的最大 ...

  5. hdu 1712 ACboy needs your help

    ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  6. hdu 1712 ACboy needs your help 分组背包

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 Problem ...

  7. 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 ( ...

  8. HDU 1712 ACboy needs your help 典型的分组背包

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1712 ACboy needs your help Time Limit: 1000/1000 MS ( ...

  9. HDU 1712 ACboy needs your help(分组背包入门题)

    http://acm.hdu.edu.cn/showproblem.php?pid=1712 题意: 有个人学习n门课程,a[i][j]表示用j分钟学习第i门课程所能获得的价值,背包容量为一共有m时间 ...

  10. queue的使用-Hdu 1702

    ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

随机推荐

  1. lua学习,笔者自用

    标识符与关键字A:常量用全大写和下划线,eg: My_ACCOUNTB: 变量的第一个字母小写,eg: strNumberC: 全局变量第一个字母用小写g表示,eg: gMyAcountD: 函数名第 ...

  2. MySQL数据库重点监控指标

    MySQL数据库重点监控指标 QPS queries per seconds 每秒中查询数量 show global status like 'Question%'; Queries/seconds ...

  3. HDU 2586 ( LCA/tarjan算法模板)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=2586 题意:n个村庄构成一棵无根树,q次询问,求任意两个村庄之间的最短距离 思路:求出两个村庄的LCA,d ...

  4. codeforces 1284B. New Year and Ascent Sequence(二分)

    B. New Year and Ascent Sequence 题意:定义上升序列Ascent,在一组序列A中,存在1<i<j<n,使得Ai<Aj.现在给定n个序列,求n个序列 ...

  5. Git的基本使用 -- 远程仓库

    SSH公钥 生成公钥 ssh-keygen -t rsa -C "xxx@xxx.com" 然后按三次回车 添加公钥 cat ~/.ssh/id_rsa.pub查看公钥 将生成的公 ...

  6. rancher布控集群启动失败

    rancher布控集群启动失败 待办 报告缺少某个文件.多线程启动任务部署的时候某些线程跑在前边了, 导致问题出现 解决思路:等待,等待响应的job重启就ok了,都是一些job在跑,失败了会重新开始的 ...

  7. Java数据处理,Map中数据转double并取小数点后两位

    BigDecimal order = (BigDecimal) map.get("finishrat"); double d = (order == null ? 0 : orde ...

  8. 【Python】 注释

    确保对模块, 函数, 方法和行内注释使用正确的风格 Python中的注释有单行注释和多行注释: Python中单行注释以 # 开头,例如:: # 这是一个注释 print("Hello, W ...

  9. kali 插上耳机没声音

    这几天装kali装的真是心力憔悴,好不容易勉强可以使用了,插上耳机想要放松下,结果没有声音? excusu me? 在经历各种方法之后终于找到了解决方法,亲测可行. 1.先打开终端,输入systemc ...

  10. codeforces 962F.simple cycle(tarjan/点双连通分量)

    题目连接:http://codeforces.com/contest/962/problem/F 题目大意是定义一个simple cycle为从一个节点开始绕环走一遍能经过simple cycle内任 ...