HDU1702 ACboy needs your help again! 题解
#include <iostream>
#include <string>
#include <queue>
#include <stack>
using namespace std;
int t, n, m; int main() {
cin >> t;
while (t--) {
queue<int>q;
stack<int>s;
string op, str;
cin >> n;
cin >> op;
if (op == "FIFO") {
while (n--) {
cin >> str;
if (str == "IN") {
cin >> m;
q.push(m);
} else {
if (q.empty()) {
cout << "None" << endl; } else {
cout << q.front() << endl;
q.pop();
}
}
}
}
if (op == "FILO") {
while (n--) {
cin >> str;
if (str == "IN") {
cin >> m;
s.push(m);
} else {
if (s.empty()) {
cout << "None" << endl;
} else {
cout << s.top() << endl;
s.pop();
}
}
}
}
} return 0;
}
HDU1702 ACboy needs your help again! 题解的更多相关文章
- hdu1702 ACboy needs your help again!(栈处理)
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdu1702 ACboy needs your help again![简单STL 栈 队列]
目录 题目地址 题干 代码和解释 参考 题目地址 hdu1702 题干 代码和解释 本题很简单,只要掌握STL stack和STL vector的语法即可作答.记录本题是为了记录STL vector的 ...
- ACboy needs your help again!--hdu1702
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU1702:ACboy needs your help again!
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- ACboy needs your help (动态规划背包)
ACboy has N courses this term, and he plans to spend at most M days on study.Of course,the profit he ...
- HDU100题简要题解(2080~2089)
//2089之前忘做了,周二C语言课上做,至于2086,写题解的时候突然发现之前的做法是错的,新的解法交上去CE,等周二再弄吧,其余题目暂时可以放心 HDU2080 夹角有多大II 题目链接 Prob ...
- 分组背包 例题:hdu 1712 ACboy needs your help
分组背包需求 有N件物品,告诉你这N件物品的重量以及价值,将这些物品划分为K组,每组中的物品互相冲突,最多选一件,求解将哪些物品装入背包可使这些物品的费用综合不超过背包的容量,且价值总和最大. 解题模 ...
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- noip2016十连测题解
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...
- BZOJ-2561-最小生成树 题解(最小割)
2561: 最小生成树(题解) Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1628 Solved: 786 传送门:http://www.lyd ...
随机推荐
- 如何将mp4文件解复用并且解码为单独的.yuv图像序列以及.pcm音频采样数据?
一.初始化解复用器 在音视频的解复用的过程中,有一个非常重要的结构体AVFormatContext,即输入文件的上下文句柄结构,代表当前打开的输入文件或流.我们可以将输入文件的路径以及AVFormat ...
- Mysql基础篇(二)之函数和约束
一. 函数 Mysql中的函数主要分为四类:字符串函数.数值函数.日期函数.流程函数 1. 字符串函数 常用函数如下: 函数 功能 CONCAT(S1, S2, ......Sn) 字符串拼接,将S1 ...
- RSA 加密签名验签解密
import javax.crypto.Cipher; import javax.crypto.spec.OAEPParameterSpec; import javax.crypto.spec.PSo ...
- C语言。格式化符号
%s 输出字符串 %d 输出整形数字 %f 输出浮点数数字 %c 输出字符 %x 输出16进制 %04d 输出长度固定的整形数字(0001,0002,....)
- Jenkins自动化测试构建完成 发送钉钉消息
背景 有时自动化测试完成后,我们可以通过构建完成后给钉钉群发消息,这样就能及时通知到所有人员了. 接入流程 1:建立钉钉机器人,可以通过群助手,添加机器人,增加WebHook自定义接入,然后添加完成会 ...
- mysql的初体验——重装解决99%的问题
这两天被java_web的作业搞得头皮发麻,主要原因就是因为jdbc连接数据库一直失败,甚至差点把电脑搞崩,删个注册表,结果用户变量也被删了,心态直接炸裂.有以下几个地方,引以为戒: 1.配置环境最好 ...
- RestSharp HTTP请求库
官方文档:https://restsharp.dev/intro.html#introduction c# RestSharp(http请求):https://blog.csdn.net/czjnoe ...
- PlayWright(二十二)- allure插件(一)
在上文中,我们介绍并使用了pytest-html插件,总之并不复杂,但是今天我们要讲一个比pytest-html插件强很多的插件allure报告,我们要掌握他并且灵活使用,之后的框架就不需要考虑其他的 ...
- 2021-7-12 VUE的生命周期
挂载: beforeCreate created beforeMount mounted:el挂载到实例上时运行 更新: beforeUpdate updated 销毁: beforeDestory ...
- 开源流量检测引擎Dalton安装记录
几个月之前照着官方文档安装过,一次性就成功,昨天重装了服务器再安装Dalton,怎么都安装不了 一直报错 ERROR: Service 'agent-suricata-current' failed ...