警示后人
查看原帖
警示后人
750589
liminghao666楼主2023/9/3 15:39
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main(){
	int t;
	cin>>t;
	while(t--){
		stack<int>q;
		int n;
		cin>>n;
		for(int i=1;i<=n;i++){
			cin>>a[i];
		}
		for(int i=1;i<=n;i++){
			cin>>b[i];
		}
		int zxc=a[n+1]=b[n+1]=1;
		for(int i=1;i<=n;i++){
			q.push(a[i]);
			while(q.size()!=0&&b[zxc]==q.top()){
				zxc++;
				q.pop();
			}
		}
		if(q.size()>0){
			cout<<"NO\n";//这里
		}else{
			cout<<"YES\n";//还有这里
		}
	}
	return 0;
} 

大小写问题

No变NO,Yes变YES

2023/9/3 15:39
加载中...