【PAT (Advanced Level) Practice】1051 Pop Sequence (25 分)
1051 Pop Sequence (25 分)
Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, if M is 5 and N is 7, we can obtain 1, 2, 3, 4, 5, 6, 7 from the stack, but not 3, 2, 1, 7, 5, 6, 4.
Input Specification:
Each input file contains one test case. For each case, the first line contains 3 numbers (all no more than 1000): M (the maximum capacity of the stack), N (the length of push sequence), and K (the number of pop sequences to be checked). Then K lines follow, each contains a pop sequence of N numbers. All the numbers in a line are separated by a space.
Output Specification:
For each pop sequence, print in one line “YES” if it is indeed a possible pop sequence of the stack, or “NO” if not.
Sample Input:
5 7 5
1 2 3 4 5 6 7
3 2 1 7 5 6 4
7 6 5 4 3 2 1
5 6
【PAT (Advanced Level) Practice】1051 Pop Sequence (25 分)相关推荐
- 【PAT甲】1051 Pop Sequence (25分)判断出栈顺序的合法性
problem 1051 Pop Sequence (25分) Given a stack which can keep M numbers at most. Push N numbers in th ...
- 【详细注释】1051 Pop Sequence (25 分)
立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given a stack which can keep M numbers at most. Push N numbers in ...
- 【PAT甲级 stack queue的使用】1051 Pop Sequence (25 分) C++ 全部AC
题目 思路 维护三个集合:核心栈.数字队列.目标队列 详细思路见注释 题解 C++ #include<iostream> #include<stack> #include< ...
- 【PAT (Advanced Level) Practice】1008 Elevator (20 分)
#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #incl ...
- PAT (Advanced Level) Practice 题解代码 - II (1051-1100)
PAT PAT (Advanced Level) Practice - II(1051-1100) -------------------------------------------------- ...
- PAT (Advanced Level) Practice 1043 Is It a Binary Search Tree (25 分) 凌宸1642
PAT (Advanced Level) Practice 1043 Is It a Binary Search Tree (25 分) 凌宸1642 题目描述: A Binary Search Tr ...
- PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642
PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...
- 【PAT (Advanced Level) Practice】1093 Count PAT‘s (25 分)
1093 Count PAT's (25 分) The string APPAPT contains two PAT's as substrings. The first one is formed ...
- 【PAT (Advanced Level) Practice】1149 Dangerous Goods Packaging (25 分)
1149 Dangerous Goods Packaging (25 分) When shipping goods with containers, we have to be careful not ...
最新文章
- Linux下MySQL的字符集乱码问题总结
- P1739 表达式括号匹配
- 流水线问题--计算机体系结构
- 【CodeForces - 485D】Maximum Value (枚举,用数组离散化,数学,取模运算,因子,筛法)
- 2021年阿里云采购季大促主会场全攻略
- mac 安装mysql怎么卸载不干净_CleanMyMac卸载不干净怎么办?如何彻底删除Mac上的CleanMyMac?...
- python内置方法怎么使用_python中的常用内置方法
- 删除隐藏版本信息 版本回退_Visual Studio Code 2019 August版本发布,新功能尝鲜
- scala代码示例_Scala元组和地图示例
- DJ音乐播放管理软件rekordbox如何从导出设备恢复音乐
- ❤️Docker教程小白实操入门 教程合集❤️
- App测试查看日志(详细)
- edu教育网邮箱注册申请普及
- SAMBA配置 “你可能没有权限访问网络资源”的问题解决方法
- 整形美容的消费者心理分析
- 厦门大学计算机学院李平,学术盛会,知行合一 ——2020年厦门大学信息学院计算机科学系研究生学术论坛圆满举办...
- 设置使用 CUDA/显卡 的编号
- 怎样和虐死人的老项目谈恋爱
- 再次定义手机摄影:华为P40系列国内正式发布
- java计算器gui(有三角函数,幂运算)