首页 > 学院 > 开发设计 > 正文

1051. Pop Sequence (25)

2019-11-11 02:10:13
字体:
来源:转载
供稿:网友

题目:https://www.patest.cn/contests/pat-a-PRactise/1051

代码:

#include<cstdio>  #include<cstring>  #include<cstdlib> #include<cmath>#include<stack>#include<string>#include<iostream>#include<algorithm>  using namespace std; int main()  {   	stack<int> s;	int m,n,k;	int a[1010];	scanf("%d%d%d",&m,&n,&k);	while(k--){		bool flag=true;		int temp=1;		while(!s.empty()){			s.pop();		}		for(int i=1;i<=n;i++){		  scanf("%d",&a[i]);		}		for(int i=1;i<=n;i++){			s.push(i);			if(s.size()>m){			  flag=false;			  break;			}			while(!s.empty()&&s.top() == a[temp]){				s.pop();				temp++;			}		}		if(s.empty() == true && flag == true){		   printf("YES/n");		}else{		  printf("NO/n");		}	 }    system("pause");  }                  


上一篇:1080

下一篇:500. Keyboard Row

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表