ZOJ 1259 Rails
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的更多相关文章
- POJ1363 Rails 验证出栈序列问题
题目地址: http://poj.org/problem?id=1363 此题只需验证是否为合法的出栈序列. 有两个思路: 1.每个已出栈之后的数且小于此数的数都必须按降序排列.复杂度O(n^2),适 ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- ZOJ题目分类
ZOJ题目分类初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 13 ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- Rails sanitize
The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements. T ...
- nginx中error_page没有生效(nginx+passenger+rails)
应用部署方式为 nginx + passenger + rails 当我想要用nginx来默认处理400以上状态时,发现在rails返回respose之后,nginx不会再次执行error_page( ...
- Ruby on Rails 创建https应用
1. 创建证书请求文件条件:私钥+证书签名请求+opensslyum install -y opensslmkdir /root/ssl/ && cd /root/ssl/openss ...
随机推荐
- BZOJ 3331 [BeiJing2013]压力-Tarjan + 树上差分
Solution Tarjan 点双缩点, 加上树上差分计算. 注意特判... 我特判挂了好久呜呜呜 Code #include<cstdio> #include<cstring&g ...
- ubuntu下为单个网卡配置多个ip
参考文档: https://www.jb51.net/os/Ubuntu/418951.html https://blog.csdn.net/ying1989920/article/details/4 ...
- 状态机学习(三)解析JSON1
来自 从零开始的 JSON 库教程 从零开始教授如何写一个符合标准的 C 语言 JSON 库 作者 Milo Yip https://zhuanlan.zhihu.com/json-tutorial ...
- 外部javascript形式
***.js: /** * 收起或者展开筛选框 */ function filterType(){ $("#filter_box_id").toggle(500); var sha ...
- 2017年多校get点
杨辉三角形变形??? lucas定理
- Python遇到ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package问题的处理办法
写Python的时候我们会遇到如下的错误: Traceback (most recent call last): File "F:/exploitation/codes/python/Jet ...
- 关于流量升高导致TIME_WAIT增加,MySQL连接大量失败的问题
有个应用就是每次都会去查一个接口,接口返回用户的信息数据,从而展现不同的页面效果.大致流程如下 应用APP(电信)-> memcache ->电信custom接口 ->master- ...
- IPython:一种交互式计算和开发环境(魔术命令,快捷键)
%run命令 在IPython会话环境中,所有文件都可以通过%run命令当做Python程序来运行. 假设在ipython_script_test.py中存放了一段简单的脚本,如下所示: def f( ...
- 树状数组(hdu-4325,hdu-1166,pat-1057)
1.hdu-4325 题意:插花,要么给出插花的范围,要么查询某个点的花的个数. 思路:通过更新,每次更新区间S到T的数值,表插入花(这一点一开始没想到), 要么查询某个点的花的数目. (与以往单纯的 ...
- GDI基础(3):绘制图片
1.CBitmap位图类封装了Windows GDI中的位图和操作位图的成员函数.CPen.CBrush.CFont.CBitmap是常用的Windows GDI对象,和CFont一样,CBitmap ...