PAT A1051 pop sequence
来源:互联网 发布:cnc编程员 编辑:程序博客网 时间:2024/05/18 00:35
模拟入栈思想
#include<cstdio>
#include<stack>#include<vector>
#include<algorithm>
using namespace std;
void check(vector<int> sq,int m){
int len=sq.size();
int i,tag=0,j=0;
stack<int> st;
for(i=1;i<=len;i++){
if(st.size()<m) st.push(i);
while((!st.empty()) && st.top()==sq[j]){
st.pop();
j++;
}
}
if(st.empty()) printf("YES\n");
else printf("NO\n");
}
int main(){
int m,n,k;
scanf("%d%d%d",&m,&n,&k);
int i,j,temp;
for(i=0;i<k;i++){
vector<int> sq;
for(j=0;j<n;j++){
scanf("%d",&temp);
sq.push_back(temp);
}
check(sq,m);
}
system("pause");
return 0;
}
0 0
- PAT A1051 Pop Sequence
- PAT A1051 pop sequence
- pat-a1051. Pop Sequence (25)
- PAT A1051. Pop Sequence (25)
- pat甲级A1051 Pop Sequence
- 栈的应用--PAT.A1051. Pop Sequence
- A1051. Pop Sequence (25)
- PAT A1051
- PAT-A1051
- pat 1051 pop sequence
- PAT 1051. Pop Sequence
- PAT Pop Sequence
- PAT-Pop Sequence (25)
- PAT 1051. Pop Sequence
- 【PAT】1051. Pop Sequence
- PAT 1051 pop Sequence
- PAT--1051. Pop Sequence
- ZJU-PAT 1051 Pop Sequence
- Django中的cookie与session
- Oracle中创建用户
- 《Spark商业案例与性能调优实战100课》第27课:彻底解密Spark Shuffle令人费解的6大经典问题
- [Azure]使用Powershell输出某台ASM虚拟机的NSG和ACL
- CF
- PAT A1051 pop sequence
- 关于mAdapter.notifyDataSetChanged()无效问题
- SpringMVC学习笔记
- 7.PHP Cookie与Session
- 二分查找
- Gradle hello world 脚本
- opencv内存释放
- 读取图片在浏览器显示
- Spark学习日志<一>