#include<cstdio>
#include<stack>
using namespace std;
const int maxn = 1010;
int arr[maxn];
stack<int>st;
int main()
{
int m, n, k;
scanf("%d%d%d", &m, &n, &k);
while (k--)
{
while (!st.empty())
{
st.pop();
}
for (int i = 1; i <= n; i++)
{
scanf("%d", &arr[i]);
}
int current = 1;
bool flag = 1;
for (int i = 1; i <= n; i++)//从1开始
{
st.push(i);
if (st.size() > m)
{
flag = 0;
break;
}
while (!st.empty() && st.top() == arr[current])
{
st.pop();
current++;
}
}
if (st.empty() && flag == 1)
{
printf("YES\n");
}
else printf("NO\n");
}
return 0;
}
A1051 Pop Sequence (25 分)
最新推荐文章于 2023-03-12 22:06:01 发布