0分求助,有点玄关
查看原帖
0分求助,有点玄关
1071829
ssssbbbbbb楼主2024/5/31 20:06

代码如下

#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int n,q,sum,b,a;
bool t=true;
stack<int>st;
int main(){
	cin>>n;
	cin>>q;
	for(int j=1;j<=n;j++){
		t=true;
		for(int i=1;i<=q;i++)
		{
			cin>>a;
			st.push(a);	
		}
		for(int y=q;y>=q;y--)
		{
			cin>>b;
			if(st.top()!=b){
				t=false; 
				break;
			}
			while(st.top()==b && !st.empty()) st.pop();
		}if(t==false) cout<<"No"<<endl;
		if(t==true) cout<<"Yes"<<endl;
	}
	return 0;
}

感谢大佬

2024/5/31 20:06
加载中...