naixvjiang @ 2023-01-31 14:39:26
#include<bits/stdc++.h>
using namespace std;
int main(){
int q;
cin>>q;
while(q--){
int n;
int a[100001],b[100001];
stack<int>st;
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n;i++)
cin>>b[i];
int head=1;
for(int i=1;i<=n;i++)
st.push(a[i]);
while(st.top()==b[head]){
st.pop();
head++;
if(st.empty())
break;
}
if(st.empty())
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}
by Jim777 @ 2023-02-03 09:43:40
嗯。。。第三个for需要括号吧。。。