求助!!!1AC4WA
查看原帖
求助!!!1AC4WA
421823
一条小沙雕ovo楼主2022/10/3 15:16
#include<bits/stdc++.h>
using namespace std;
int nn,n,b,top,top2;
int main(){
	cin>>nn;
	for(int k=1;k<=nn;k++){
		top=1;
		top2=1;
		int a[100005]={};
		int c[100005]={};
		bool bb=0;
		cin>>n;
		for(int i=1;i<=n;i++){
			cin>>a[i];
		}
		for(int i=1;i<=n;i++){
			cin>>b;
			while(c[top-1]!=b){
				if(top2>n+1){
					cout<<"No"<<endl;
					bb=1;
					break;
				}
				c[top++]=a[top2++];
			}
			top--;
			if(bb)break;
		}
		if(bb)continue;
		else if(c[top-1]==0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}
2022/10/3 15:16
加载中...