闲鱼钓鱼网站怎么弄:浙大 1259 火车

来源:百度文库 编辑:九乡新闻网 时间:2024/04/28 06:19:20
#include#include#include#includeconst int MAXN = 1000 +10;int n; int target[MAXN];
int main(){    while(scanf("%d",&n)&&n)    {       while(scanf("%d",&target[1])&&target[1])    {      int stack[MAXN],top = 0;      int A= 1,B=1;      for(int i=2; i<=n; i++)      scanf("%d",&target[i]);      int ok = 1;      while(B<=n)      {        if(A == target[B]){ A++;B++; }         else if(top&&stack[top]==target[B]){top--; B++; }         else if(A <= n)stack[++top]=A++;         else {ok = 0; break;}      }      printf("%s\n",ok?"Yes":"No");    }   if(n)printf("\n");           }     system("pause");return 0;}