C++ RE 20pts求调
查看原帖
C++ RE 20pts求调
1017223
蒟蒻whker楼主2024/9/7 15:31

rt

#include <bits/stdc++.h>
using namespace std;
int main(){
int t;cin>>t;
	stack<int>q;
while(t--){
	int n,now=1;
	cin>>n;
	int a[1005],b[1005];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<=n;i++){
		q.push(a[i]);
			while(q.top()==b[now]){
				q.pop();now++;
				if(q.empty())break;
		}
	}
	if(q.empty())cout<<"Yes";else cout<<"No";
	puts("");
	while(!q.empty())q.pop();
}
return 0;
}
2024/9/7 15:31
加载中...