stack的应用

 #include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
int goal[];
int d[];
stack<int>s;
int main()
{
freopen("input.txt","r",stdin);
int n;
for(int i = ; i <= ; i++)
d[i] = i;
while(cin>>n && n)
{
while(cin>>goal[] && goal[])
{
while(!s.empty())
s.pop();
for(int i = ; i <= n; i++)
cin>>goal[i];
int i = ;
int pos = ;
s.push(d[]);
while(pos <= n && i <= n+)
{
if(s.empty() || s.top() != goal[pos])
{
s.push(d[i]);
i++;
}
else if(s.top() == goal[pos])
{
s.pop();
pos++;
}
else break;
}
if(s.empty())
cout<<"Yes"<<endl;
else cout<<"No"<<endl; }
cout<<endl;
}
return ;
}

ZOJ 1259 Rails的更多相关文章

  1. POJ1363 Rails 验证出栈序列问题

    题目地址: http://poj.org/problem?id=1363 此题只需验证是否为合法的出栈序列. 有两个思路: 1.每个已出栈之后的数且小于此数的数都必须按降序排列.复杂度O(n^2),适 ...

  2. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  3. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  4. ZOJ题目分类

    ZOJ题目分类初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 13 ...

  5. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  6. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  7. Rails sanitize

    The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements. T ...

  8. nginx中error_page没有生效(nginx+passenger+rails)

    应用部署方式为 nginx + passenger + rails 当我想要用nginx来默认处理400以上状态时,发现在rails返回respose之后,nginx不会再次执行error_page( ...

  9. Ruby on Rails 创建https应用

    1. 创建证书请求文件条件:私钥+证书签名请求+opensslyum install -y opensslmkdir /root/ssl/ && cd /root/ssl/openss ...

随机推荐

  1. dede 栏目及子栏目

    结果如图: <ul class="bottom_ul"> {dede:channelartlist } <li><a href="{dede ...

  2. python 截取某一天的日志,简单操作

    #!/usr/bin/python #Filename: Segmentation_log.py import re,sys def openfile(*args): try: f=open(args ...

  3. KeyPress键盘按键ASCII值对应表

    vbKeyLButton 1 鼠标左键  vbKeyRButton 2 鼠标右键  vbKeyCancel 3 CANCEL 键  vbKeyMButton 4 鼠标中键  vbKeyBack 8 B ...

  4. ubuntu如何实现双屏显示

    转载自https://blog.csdn.net/tianmaxingkong_/article/details/50570538

  5. YII配置mysql读写分离

    Mysql 读写分离 YIi 配置 <?php return [ 'class' => 'yii\db\Connection', 'masterConfig' => [ // 'ds ...

  6. Vue 使用中的小技巧

    在vue的使用过程中会遇到各种场景,当普通使用时觉得没什么,但是或许优化一下可以更高效更优美的进行开发.下面有一些我在日常开发的时候用到的小技巧,在下将不定期更新~ 1.多图表resize事件去中心化 ...

  7. Twitter 相关APP开发

    首先要获取 Consumer Key (API Key), Consumer Secret (API Secret):最好申请Access Token 和Access Token Secret,不然验 ...

  8. 【Web】网页清除浮动的方法

    网页中,经常用浮动的div来布局,但是会出现父元素因为子元素浮动引起内部高度为0的问题,为了解决这个问题,我们需要清除浮动,下面介绍4中清除浮动的方法. 在CSS中,clear属性用户清除浮动,语法: ...

  9. NOIP2017提高组预赛详解

    NOIP2017预赛终于结束了. 普遍反映今年的卷子难度较大,但事实上是这样吗?马上我将为您详细地分析这张试卷,这样你就能知道到底难不难. 对了答案,鄙人考得还是太差了,只有91分. 那么下面我们就一 ...

  10. mysql字符串类型数据

    字符串类型是在数据库中存储字符串的数据类型,字符串类型包括char,varchar,text,enum和set. OK,我们来一个一个的看下上面提到的几种类型. char类型和varchar类型 ch ...