zoukankan      html  css  js  c++  java
  • hoj 1067 Rails //poj1363 Rails 栈的简单应用

    //ACM ICPC Central European Regional 1997

    /*

    简单的栈的应用,可惜WA了好几次

    poj上要把最后的while后的cout<<endl;去掉

    */

    #include <iostream>

    #include <stack>

    #include <cstdio>

    using namespace std;

    const int X = 1005;

    int a[X],b[X];

    int main()

    {

       freopen("sum.in","r",stdin);

       freopen("sum.out","w",stdout);

       int n,x,t = 0;

       while(cin>>n,n)

       {

          if(t++)

             cout<<endl;

          while(cin>>x,x)

          {

             stack<int> s;

             a[1] = x;

             for(int i=2;i<=n;i++)

                scanf("%d",a+i);

             int cnt = 1;

             int B = 1;

             for(int i=1;i<=n;i++)

             {

                s.push(i);

                if(s.top()==a[cnt])

                {

                    while(!s.empty())

                    {

                       if(s.top()==a[cnt])

                       {

                          b[B++] = s.top();

                          cnt++;

                          s.pop();

                       }

                       else

                          break;

                    }

                }

             }

             bool flag = true;

             for(int i=1;i<=n;i++)

                if(a[i]!=b[i])

                {

                    flag = false;

                    cout<<"No"<<endl;

                    break;

                }

             if(flag)

                cout<<"Yes"<<endl;

          }

       }

       cout<<endl;

       return 0;

    }

     

    编辑器加载中...

  • 相关阅读:
    UVA120Stacks of Flapjacks
    [.NET] 基于windows mobile 5.0 开发环境配置说明
    C#实现UDP打洞
    webBrowser对跳转后的页面的处理
    Windows Mobile程序环境配置以及Windows Mobile与PC进行UDP通信总结
    C#【Fox即时通讯核心】 开发记录之三(知识储备:TCP UDP打洞)
    jqplot统计图工具简单例子
    订单编号
    windows mobile 5.0 PocketPC模拟器上网的设置 【正确】
    今明2年主要目标20112012
  • 原文地址:https://www.cnblogs.com/yejinru/p/2414165.html
Copyright © 2011-2022 走看看