#include <iostream>
#include<stdlib.h>
#include<vector>
using namespace std;
vector<int>v;
int m, n, k;
bool isok() {
vector<int>test;
int maxnum = 0;//入过栈的最大值
for (int i = 0; i < n; i++) {
if (test.size() == 0||maxnum < v[i]){
for (int j = maxnum+1; j <= v[i];j++) {
test.push_back(j);
}
if (test.size() > m)
return false;
maxnum = v[i];
}
if (test.back() == v[i])
test.pop_back();
else
return false;
}
return true;
}
int main() {
scanf("%d%d%d", &m, &n, &k);
for (int i = 0; i < k; i++) {
v.clear();//clear之后大小会变吗,会变成0
for (int j = 0; j < n; j++) {
int num;
scanf("%d", &num);
v.push_back(num);
}
isok()?printf("YES\n"):printf("NO\n");
}
return 0;
}
pat甲级1051
猜你喜欢
转载自blog.csdn.net/csdnnmbdybb/article/details/88114148
今日推荐
周排行