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 ...
随机推荐
- Spring 循环引用(一)一个循环依赖引发的 BUG
Spring 循环引用(一)一个循环依赖引发的 BUG Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) Spring 循环 ...
- wifi功能模块
1. API 10 Android2.3.3 不支持wifi代理设置. 2017-09-29 原来addOrUpdateNetwork之前,wifi配置并不会立即生效,要想立即生效,就要 wifiMa ...
- wepy中页面的跳转
1.在pages中创建好页面之后,需要在app.wpy中的config中配置好页面路由:2.如果跳转的按钮在page页面中 this.$navigate({url:"content" ...
- velocity 框架
Java模板引擎 Velocity是一个基于java的模板引擎(template engine).它允许任何人仅仅使用简单的模板语言(template language)来引用由java代码定义的对象 ...
- Linux学习笔记:Jenkins的使用
在windows中使用Jenkins(Linux系统下类似),步骤是: 1 从官网下载jenkins项目的war包 2 将jenkins.war放到tomcat的webapps目录中,启动tomcat ...
- 【Java】生成图形验证码
本章介绍一个能生成比较好看的图形验证码类 生成验证码工具类 package com.util; import java.awt.Color; import java.awt.Font; import ...
- json(原生态)
什么是 JSON ? JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation) JSON 是轻量级的文本数据交换格式 JSON 独立于语言 * JSO ...
- sql number类型和varchar2类型
查询时,发现org_id 为number类型,zone_id为varchar2类型,需要转化 转换 to_char(),或者to_number select a.id,b.col,a.col from ...
- Maven手动将jar包放入本地仓库
mvn install:install-file -Dfile=jar包的位置 -DgroupId=上面的groupId -DartifactId=上面的artifactId -Dversion=上面 ...
- web程序打包详解
重要更新:鉴于很多小伙伴们说看不到图,我这边换了几个浏览器看了下,都看得到的,估计是网速问题,请耐心等待,另外,为了更好的方便大家学习,特此提供源码以及一个word文档,word文档就是本文内容 ...