pat甲级A1051 Pop Sequence
来源:互联网 发布:淘宝原产地政府背书 编辑:程序博客网 时间:2024/06/05 08:08
看书敲的代码,仅用来记录自己的成长
#include <cstdio>#include <stack>using namespace std;const int maxn = 1010;int arr[maxn];stack<int> st;int main(){ int m,n,T; scanf("%d%d%d",&m,&n,&T); while(T--) { while(!st.empty()) { st.pop(); } for(int i=1;i<=n;i++) { scanf("%d",&arr[i]); } int current = 1; bool flag = true; for(int i=1;i<=n;i++) { st.push(i); if(st.size() > m) { flag = false; break; } while(!st.empty()&&st.top()==arr[current]) { st.pop(); current++; } } if(st.empty()==true && flag==true) { printf("YES\n"); }else { printf("NO\n"); } } return 0; }
0 0
- pat甲级A1051 Pop Sequence
- PAT A1051 Pop Sequence
- PAT A1051 pop sequence
- pat-a1051. Pop Sequence (25)
- PAT A1051. Pop Sequence (25)
- 栈的应用--PAT.A1051. Pop Sequence
- A1051. Pop Sequence (25)
- 【PAT甲级】1051. Pop Sequence (25)
- 1051. Pop Sequence (25)PAT甲级
- PAT甲级练习1051. Pop Sequence (25)
- PAT甲级1051. Pop Sequence (25)
- PAT 甲级 1051. Pop Sequence (25)
- PAT甲级 1051. Pop Sequence (25)
- 1051. Pop Sequence (25)-PAT甲级真题
- PAT A1051
- PAT-A1051
- pat 1051 pop sequence
- PAT 1051. Pop Sequence
- 用GitHub和Hexo搭建自己的博客
- 优化 | 提高InnoDB表BLOB列的存储效率
- SharedPrefences
- ionic ng-bind-html
- c语言实现 在一个字符串中找到由同一个字符组成的最长子串
- pat甲级A1051 Pop Sequence
- centos7和linux防火墙配置入门
- 选拔赛之 kmp
- 剑指offer-链表中环的入口节点-php
- 现代前端技术解析(4)
- [李景山php]每天laravel[035]-laravel 基础知识 --- Eloquent 模型之关系映射
- 科锐课堂笔记:2017/4/10 构造函数与析构函数
- androidSQLite使用
- Spring框架学习(5):bean之间的关系