POJ 1363 Rails(栈)】的更多相关文章

思路:将出车站的顺序存入数组train,由于入车站的顺序是固定的,为1~N,所以用P表示进站的车,初始为1. 接下来举例说明吧: 原来入站顺序:    1 2 3 4 5 读入的出战顺序: 3 4 2 5 1 按照train数组的顺序来执行, 1.一开始p=1,i=1: p与train[i]=3不相等,将p(1)入栈,p++:再比较不相等,将p(2)入栈,p++: p=train[3],则i++,p++: 2.i=2: 先比较train[i]与栈顶元素2是否相同,不相同,则与p比较. train…
题目代号:POJ 1363 题目链接:http://poj.org/problem?id=1363 题目原题: Rails Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 34585   Accepted: 13434 Description There is a famous railway station in PopPush City. Country there is incredibly hilly. The s…
问题如下: 问题 B: Rails 时间限制: Sec 内存限制: MB 提交: 解决: [提交][状态][讨论版] 题目描述 There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was…
Rails Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25964   Accepted: 10199 Description There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds w…
题目链接:http://poj.org/problem?id=1363 题意:有一列火车,车厢编号为1-n,从A方向进站,向B方向出站.现在进站顺序确定,给出一个出站的顺序,判断出站顺序是否合理. 实际上是模拟栈的过程,而栈的特点是先进后出.另外一个麻烦的地方就是输入输出格式问题. 本题实现提供两种方法:没有用到STL栈和有用到STL栈 #include <iostream> // 法二:头文件多包含一个 #include <stack> using namespace std;…
1.链接: http://poj.org/problem?id=1363 http://bailian.openjudge.cn/practice/1363 2.题目: Rails Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24612   Accepted: 9644 Description There is a famous railway station in PopPush City. Country ther…
Rails Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21728   Accepted: 8703 Description There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds we…
poj1363,这道题是数据结构与算法中的经典问题,给定一组进栈顺序,问栈有多少种出去的顺序. #include<stdio.h> #include <stack> #include <iostream> #include <cstring> using namespace std; int main() { // freopen("in.txt","r",stdin); int n; while(scanf(&quo…
Description There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish only a surface track. Moreove…
1.Poj 3250  Bad Hair Day 2.链接:http://poj.org/problem?id=3250 3.总结:单调栈 题意:n头牛,当i>j,j在i的右边并且i与j之间的所有牛均比i矮,i就可看到j.i可看到的所有牛数记为ai,求S(ai),(1<=i<=n). 转化一下,求j可以被多少牛看到.这样就直接单调栈,求从j往前单调递增的数量. #include<iostream> #include<cstring> #include<cma…