听取WA声一片
查看原帖
听取WA声一片
1430495
litianrui0201楼主2025/1/21 11:25
#include<bits/stdc++.h>
using namespace std;
void judge(stack<int> pushedt,stack<int> poped){
	while(!pushedt.empty( )&&!poped.empty( )){
		if(pushedt.top( )!=poped.top( )){
			cout<<"No"<<endl;
			return;
		}
		pushedt.pop( );
		poped.pop( );
	}
	cout<<"Yes"<<endl;
}
int main( ){
	int Q;cin>>Q;
	while(Q--){
		stack<int> pushed;
		stack<int> poped;
		stack<int> pushedt;
		int n;cin>>n;
		for(int i=0;i<n;i++){
			int j;cin>>j;
			pushed.push(j);
		}
		for(int i=0;i<n;i++){
			int j;cin>>j;
			poped.push(j);
		}
    //输入
		while(!pushed.empty( )){
			pushedt.push(pushed.top( ));
			pushed.pop( );
		}
    //把pushed转换成倒序的
		judge(pushedt,poped);
    //判断是yes还是No
	}
	return 0;
}
2025/1/21 11:25
加载中...