zzdkf20081224 @ 2024-08-09 10:29:17
using namespace std;
int q,n,a[100005],b[100005];
stack<int> m;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>q;
for(int i=1;i<=q;i++){
int top=1;
cin>>n;
for(int j=1;j<=n;j++){
cin>>a[j];
}
for(int j=1;j<=n;j++){
cin>>b[j];
}
while(!m.empty()) m.pop();
for(int j=1;j<=n;j++){
m.push(a[j]);
while(!m.empty()&&b[top]==m.top()){//在这里加empty()防止数组越界
top++;
m.pop();
}
}
if(m.empty()) cout<<"YES"<<"\n";
else cout<<"NO"<<"\n";
}
return 0;
}
by 7_NYQ @ 2024-08-10 11:24:04
输出字母大小写错了