1.题目介绍
2.考察点,难度
模拟现实类,模拟堆栈,数据结构,难度易
3.解题代码
#include <cstdio>
#include <stack>
using namespace std;
int main()
{
int m, n, k;
scanf("%d %d %d", &m, &n, &k);
for (int i = 0; i < k; i++){
int seq[n+1];
stack<int> pop;
for (int j = 1; j < n+1; j++) scanf("%d", seq+j);
int current = 1;
for (int j = 1; j < n+1; j++){
pop.push(j);
if (pop.size() > m) break;
while (!pop.empty() && pop.top() == seq[current]){
pop.pop();
current++;
}
}
if (current < n+1) printf("NO\n");
else printf("YES\n");
}
return 0;
}