UVa 514(栈)铁轨
程序员文章站
2022-04-09 12:47:44
...
#include<iostream>
using namespace std;
int s[100000],top;
int main()
{
int n,t;
while(scanf("%d",&n)&&n)
{
while(1)
{
int f=0;
int k=1,top=1;
scanf("%d",&t);
if(t==0) break;
while((top==1||s[top-1]!=t)&&k<=n) s[top++]=k++;
if(top>1&&s[top-1]==t) --top;
else f=1;
for(int i=1; i<n; ++i)
{
scanf("%d",&t);
if(f) continue;
while((top==1||s[top-1]!=t)&&k<=n) s[top++]=k++;
if(top>1&&s[top-1]==t) --top;
else f=1;
}
puts(!f?"Yes":"No");
}
puts("");
}
return 0;
}
上一篇: 【MySQL】MySQL From主从复制To双机热备
下一篇: Mysql主从备份配置