1051. Pop Sequence (25)
来源:互联网 发布:淘宝书店转让 编辑:程序博客网 时间:2024/05/18 07:41
模拟压栈、弹栈操作,判断合法性
#include <iostream>#include <cstdio>#include <stack>using namespace std;int main(){int m, n, k;scanf("%d%d%d", &m, &n, &k);for(int i = 0; i < k; ++i){stack<int> s;bool valid = true;int curr = 1;for(int j = 0; j < n; ++j){int num;scanf("%d", &num);if(valid){while(s.empty() || s.top() != num){s.push(curr++);if((int)s.size() > m){valid = false;break;}}if(valid && s.size() && s.top() == num) s.pop();}}if(valid) printf("YES\n");else printf("NO\n");}return 0;}
0 0
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)
- Struts2 学习笔记之一
- springmvc 传入controller乱码
- 1072: [SCOI2007]排列perm 状压DP
- 搭建简易在线聊天室
- c++中类的多态和虚函数的使用
- 1051. Pop Sequence (25)
- 大型分布式网站架构技术总结
- 哈理工 OJ 2215 Angle(简单的思维题)
- hdu 1864 最大报销额
- Python 下载文件
- XAPP的使用
- linux下安装配置tftp服务器
- Android Hanlder小例子
- GreenPlum安装性能监控工具GPCCC(Greenplum Command Center Console)