#include<cstdio>
#include<iostream>
#include<queue>
#include<list>
#include<string>
using namespace std;
int a[100000],b[100000],len=0,c[100000];
void push(int p){
c[++len]=p;
}
void pop(){len--;}
int top(){return c[len];}
bool empty(){
if(len==0)return 1;
else return 0;
}
main()
{int q,n,o,head=1;
cin>>q;
for(int i=1;i<=q;i++){
cin>>n;
for(int j=1;j<=n;j++){cin>>a[j];}
for(int j=1;j<=n;j++){cin>>b[j];}
for(int j=1;j<=n;j++){
push(a[j]);
while(c[len]==b[head]){
pop();
head++;
if(empty())break;
}
}
if(empty())cout<<"Yes"<<endl;
else cout<<"No"<<endl;
len=1;
}
return 0;
}
样例和我自己的值都试过了
看题解也不知道问题在哪。。