hdu 1702 ACboy needs your help again!
2015-06-17 18:17
651 查看
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1702
[code]#include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<vector> #include<queue> #include<stack> #include<map> #include<set> using std::cin; using std::cout; using std::endl; using std::find; using std::sort; using std::set; using std::map; using std::pair; using std::stack; using std::queue; using std::vector; #define sz(c) (int)(c).size() #define all(c) (c).begin(), (c).end() #define iter(c) decltype((c).begin()) #define cls(arr,val) memset(arr,val,sizeof(arr)) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i) #define pb(e) push_back(e) #define mp(a, b) make_pair(a, b) const int Max_N = 100010; typedef unsigned long long ull; queue<int> que; stack<int> stk; int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w+", stdout); #endif int n, v, t; char buf[10]; scanf("%d", &t); while (t--) { scanf("%d %s", &n, buf); if ('F' == buf[2]) { rep(i, n) { scanf("%s", buf); if ('I' == buf[0]) scanf("%d", &v), que.push(v); else { if (que.empty()) { puts("None"); continue; } printf("%d\n", que.front()), que.pop(); } } } else { rep(i, n) { scanf("%s", buf); if ('I' == buf[0]) scanf("%d", &v), stk.push(v); else { if (stk.empty()) { puts("None"); continue; } printf("%d\n", stk.top()), stk.pop(); } } } while (!stk.empty()) stk.pop(); while (!que.empty()) que.pop(); } return 0; }
相关文章推荐
- 从Clarifai的估值聊聊深度学习
- UVa 10551 - Basic Remains
- [AIR] 检测移动设备运动
- youwuku和koudaitong以及weimeng差异
- iphone使用keychain来存取用户名和密码
- RHEL6.4 安装 highpoint RocketRAID 2720 阵列卡驱动
- Xcode运行出错Installation Failed Invalid argument
- linux下,使用opencv训练级联分类器opencv_traincascade
- Installation error: INSTALL_FAILED_CPU_ABI_INCOMPATIBLE
- 浅谈使用NIO,AIO的感受
- 关于:HTTP Header -> Content-Type: text/plain Cache-Control: no-cache IE浏览器弹出错误下载对话
- linux环境下使用opencv训练级联分类器traincascade
- hdoj 1022 Train Problem I
- 【ORA-00060】 deadlock detected while waiting for resource
- 记AWSome Day Shanghai 150612
- Could not reliably determine the server's fully qualified domain name?
- HDU 1337 The Drunk Jailer--(模拟题找规律)
- 当摄像机被墙挡住后,墙消失,相反则出现(三维坐标到二维坐标的转换实例Camera.main.WorldToScreenPoint)
- raid简介
- http://daikainan.iteye.com/blog/1405575