ZDiu @ 2024-01-19 14:45:46
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
int q;
int main(){
cin>>q;
stack<int> s[q];
vector<int> v[q];
for(int i=0;i<q;i++){
int n;
cin>>n;
//入栈序列
for(int j=1;j<=n;j++){
//TODO
int temppush;
cin>>temppush;
s[i].push(temppush);
}
//出栈序列用vector存粹
for(int j =1;j<=n;j++){
//TODO
int temppop;
cin>>temppop;
v[i].push_back(temppop);
}
}
//数据初始化完成
for(int i=0;i<q;i++){
//TODO
int flag =0;
while(!s[i].empty()){
//TODO
int temp1;
temp1=s[i].top();
s[i].pop();
int temp2=v[i].front();
v[i].erase(v[i].begin());
if(temp1!=temp2){
//TODO
flag=1;
}
}
if(flag == 0){
//TODO
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
return 0;
}