简单题。

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
#include<string>
#include<stack>
#include<vector>
using namespace std; int n,k,m;
int a[+];
stack<int>S; bool check()
{
while(!S.empty()) S.pop();
int Max=,sz=;
int now=;
int p=;
while()
{
int tmp=sz;
if(S.empty()&&p<=k)
{
S.push(p++);
sz++;
Max=max(sz,Max);
}
else
{
if(S.top()==a[now])
{
S.pop(); now++;
sz--;
}
else
{
if(p<=k)
{
S.push(p++);
sz++;
Max=max(sz,Max);
}
}
}
if(now==k+||sz==tmp) break;
}
if(Max<=m&&now==k+) return ;
return ;
} int main()
{
scanf("%d%d%d",&m,&k,&n);
for(int i=;i<=n;i++)
{
for(int j=;j<=k;j++) scanf("%d",&a[j]);
if(check()) printf("YES\n");
else printf("NO\n");
} return ;
}

PAT (Advanced Level) 1051. Pop Sequence (25)的更多相关文章

  1. PAT 解题报告 1051. Pop Sequence (25)

    1051. Pop Sequence (25) Given a stack which can keep M numbers at most. Push N numbers in the order ...

  2. 【PAT甲级】1051 Pop Sequence (25 分)(栈的模拟)

    题意: 输入三个正整数M,N,K(<=1000),分别代表栈的容量,序列长度和输入序列的组数.接着输入K组出栈序列,输出是否可能以该序列的顺序出栈.数字1~N按照顺序随机入栈(入栈时机随机,未知 ...

  3. PAT (Advanced Level) 1085. Perfect Sequence (25)

    可以用双指针(尺取法),也可以枚举起点,二分终点. #include<cstdio> #include<cstring> #include<cmath> #incl ...

  4. PAT 甲级 1051 Pop Sequence (25 分)(模拟栈,较简单)

    1051 Pop Sequence (25 分)   Given a stack which can keep M numbers at most. Push N numbers in the ord ...

  5. PAT 1051 Pop Sequence (25 分)

    返回 1051 Pop Sequence (25 分)   Given a stack which can keep M numbers at most. Push N numbers in the ...

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

  7. 【PAT】1051 Pop Sequence (25)(25 分)

    Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and p ...

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

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

随机推荐

  1. FCFS

    (First Come First Served) 按照作业进入系统的先后次序来挑选作业,先进入系统的作业优先被挑选. FCFS算法的优缺点: 算法容易实现.但效率不高,只顾及作业等候时间,没考虑作业 ...

  2. find排除目录

    在linux find 进行查找的时候,有时候需要忽略某些目录不查找,可以使用 -prune 参数来进行过滤,但必须要注意要忽略的路径参数必须紧跟着搜索的路径之后,否则该参数无法起作用. 命令语法: ...

  3. hdu_3555_Bomb(数位DP)

    题目连接:hdu_3555_Bomb 题意:和2089一样,只是数据大了点,不过道理是一样的 #include<cstdio> #include<cstring> #defin ...

  4. iOS传值之通知传值(三)

    输入所要发送的信息 ,同时将label的值通过button方法调用传递, - (IBAction)buttonClick:(id)sender { //添加 字典,将label的值通过key值设置传递 ...

  5. openCV(三)---图像缩放

    UIImage *img1 = [UIImage imageNamed:@"1448941176867"]; //将UIImage转换为IplImage格式 IplImage *p ...

  6. C#抓取页面时候,获取页面跳转后的地址

    static string fanhuiurl(string cahxunurl) { string url = ""; HttpWebRequest req = (HttpWeb ...

  7. spring XML格式

    使用spring遇见一个很坑的问题,在XML中 这样配置: <method name="newSoapParam2" parameters="java.lang.S ...

  8. 【转】curl 查看一个web站点的响应时间(rt)

    原文: http://blog.csdn.net/caoshuming_500/article/details/14044697 1. curl 查看web站点rt curl -o /dev/null ...

  9. Openlayers 3 热力图

    <body> <div id="map"></div> <script> var map = new ol.Map({ //初始化m ...

  10. Hibernate 系列教程1-枚举单例类

    你还在为不知道怎样正确使用Hibernate而纠结吗 你还在为不知道怎样配置映射文件而郁闷吗 枚举单例(Enum Singleton) 是实现单例模式的一种方式而已,不过写法简单,创建枚举默认也是线程 ...