AUV,您瞧瞧,写个模拟栈嗨不让过了
查看原帖
AUV,您瞧瞧,写个模拟栈嗨不让过了
1168588
FASTergood楼主2024/10/16 19:41

样例都过了,全wa,求各位爷瞧瞧

#include<algorithm>
#include<iostream>
#include<stack>
#include<cstring>
#include<map>
using namespace std;
#define int long long
const int N=1e6+10;
int stk[N];
bool val[N];
int n,m,t;
//map<char,bool>val;
stack<char>q;
signed main()
{
	cin>>n;
	while(n--)
	{
		int flag=0;
		memset(stk,0,sizeof(stk));
		int hh=0;
		cin>>m;
		
		for(int i=1;i<=m;i++)
		{
			int x;
			cin>>x;
			stk[++hh]=x;
		}
		for(int i=m;i>=1;i--)
		{
			int y;
			cin>>y;
			if(stk[hh--]==y)continue;
			else {
				
				flag=1;
				//break;
			}
		}
		if(flag==0)
		cout<<"Yes"<<endl;
		else 
			cout<<"No"<<endl;
		
	}
}

地道

2024/10/16 19:41
加载中...