求助
查看原帖
求助
970515
Warriors_Curry楼主2024/7/24 15:50

一直输出NO,啊啊啊

#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll z[100005],a[100005],top,tot=0,n;
bool fe()
{
	tot=0;
	top=0;
	for(ll i=0;i<n;i++)
	{
		while((a[i]!=z[top]||top==0)&&top<n)
		{
			z[++top]=++tot;
		}
		if(a[i]==z[top]) top--;
		else return 0;
	}
	return 1;
}
int main()
{
	while(cin>>n)
	{
		if(n==0) break;
		ll x;
		while(cin>>x)
		{
			if(x==0) break;
			for(ll i=1;i<n;i++) cin>>a[i];
			if(fe()==1) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
		
	}
	
	return 0;
}
2024/7/24 15:50
加载中...