#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
int st[10010];
int a[1010];
int main()
{
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif // LOCAL
int m,n,k;
cin>>m>>n>>k;
while(k--){
int top=-1;
int flag=1;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int cur=1;
for(int i=1;i<=n;i++){
st[++top]=i;
if(top>=m){
flag=0;
break;
}
while(top!=-1&&st[top]==a[cur]){
cur++;
top--;
}
}
if(top==-1&&flag==1)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
【PAT】1051. Pop Sequence
最新推荐文章于 2024-04-25 10:28:26 发布