题目:
思路分析:
就是一个简单的栈模拟!
代码实现:
const int MAX=100100;
int main(){
int n,m,k;
cin>>n>>m>>k;
while (k--) {
int next=1;
stack<int>st;
int flag=1;
for(int i=1;i<=n;i++){
int x;
cin>>x;
if(x==next){
next++;
while (!st.empty()) {
if(st.top()==next){
next++;
st.pop();
}
else break;
}
}
else {
st.push(x);
if(st.size()>m){
flag=0;
}
}
}
if(flag&&st.size()==0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}