代码如下
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int n,q,sum,b,a;
bool t=true;
stack<int>st;
int main(){
cin>>n;
cin>>q;
for(int j=1;j<=n;j++){
t=true;
for(int i=1;i<=q;i++)
{
cin>>a;
st.push(a);
}
for(int y=q;y>=q;y--)
{
cin>>b;
if(st.top()!=b){
t=false;
break;
}
while(st.top()==b && !st.empty()) st.pop();
}if(t==false) cout<<"No"<<endl;
if(t==true) cout<<"Yes"<<endl;
}
return 0;
}
感谢大佬