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 分)相关推荐

  1. 【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 ...

  2. 【详细注释】1051 Pop Sequence (25 分)

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given a stack which can keep M numbers at most. Push N numbers in ...

  3. 【PAT甲级 stack queue的使用】1051 Pop Sequence (25 分) C++ 全部AC

    题目 思路 维护三个集合:核心栈.数字队列.目标队列 详细思路见注释 题解 C++ #include<iostream> #include<stack> #include< ...

  4. 【PAT (Advanced Level) Practice】1008 Elevator (20 分)

    #include<iostream> #include<cstdio> #include<cstdlib> #include<string> #incl ...

  5. PAT (Advanced Level) Practice 题解代码 - II (1051-1100)

    PAT PAT (Advanced Level) Practice - II(1051-1100) -------------------------------------------------- ...

  6. 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 ...

  7. 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 ...

  8. 【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 ...

  9. 【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 ...

最新文章

  1. Linux下MySQL的字符集乱码问题总结
  2. P1739 表达式括号匹配
  3. 流水线问题--计算机体系结构
  4. 【CodeForces - 485D】Maximum Value (枚举,用数组离散化,数学,取模运算,因子,筛法)
  5. 2021年阿里云采购季大促主会场全攻略
  6. mac 安装mysql怎么卸载不干净_CleanMyMac卸载不干净怎么办?如何彻底删除Mac上的CleanMyMac?...
  7. python内置方法怎么使用_python中的常用内置方法
  8. 删除隐藏版本信息 版本回退_Visual Studio Code 2019 August版本发布,新功能尝鲜
  9. scala代码示例_Scala元组和地图示例
  10. DJ音乐播放管理软件rekordbox如何从导出设备恢复音乐
  11. ❤️Docker教程小白实操入门 教程合集❤️
  12. App测试查看日志(详细)
  13. edu教育网邮箱注册申请普及
  14. SAMBA配置 “你可能没有权限访问网络资源”的问题解决方法
  15. 整形美容的消费者心理分析
  16. 厦门大学计算机学院李平,学术盛会,知行合一 ——2020年厦门大学信息学院计算机科学系研究生学术论坛圆满举办...
  17. 设置使用 CUDA/显卡 的编号
  18. 怎样和虐死人的老项目谈恋爱
  19. 再次定义手机摄影:华为P40系列国内正式发布
  20. java计算器gui(有三角函数,幂运算)

热门文章

  1. pyzbar Unable to find zbar shared library
  2. dataframe获取指定列
  3. python and or 优先级
  4. pytorch cross_entropy
  5. 在Java中调用Python
  6. 神经网络 Log-Sum-Exp
  7. map按value值查找——find_if的使用(转载)
  8. NMS和soft-nms算法
  9. ubuntu查看文件和文件夹大小
  10. opencv的ROI操作