#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#define N 100005
#define ll long long
using namespace std;
int a[1005];
stack<int>s;
int main()
{
int n,m,k,i,j;
while(scanf("%d%d%d",&m,&n,&k)!=EOF)
{
while(k--)
{
while(!s.empty())s.pop();
for(i = 1;i<=n;i++)scanf("%d",&a[i]);
i = j = 1;
while(i<=n)
{
while((s.empty()||s.top()!=a[i])&&j<=n&&s.size()<m)s.push(j++);
if(s.top() == a[i])
{
s.pop();
i++;
}
else break;
}
if(s.empty())printf("YES\n");
else printf("NO\n");
}
}
return 0;
}
pat1051 Pop Sequence
最新推荐文章于 2020-02-09 14:24:21 发布