栈模拟View Code #include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <stack>using namespace std;#define maxn 1005int n;int f[maxn];void input(){ for (int i = 1; i < n; i++) scanf("%d", &f[i]);}bool ok(){ stack<int> stk; in
转载 2013-01-18 11:11:00
767阅读
2评论
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. I
转载 2017-06-22 08:55:00
124阅读
2评论
Description There is a famous railway station in PopPush City. Country
转载 2013-07-22 19:52:00
115阅读
2评论
题目解答判断出栈顺序#include <iostream>#include <string>#include <list>#include <stack>#include <cassert>// POJ 1363 Rails// 这是一种模拟思想。 想办法将data_list的数通过一个栈的操作实现出pop_sequence这个序列。bool IsRightPopSequence(std::list<int>
原创 2021-12-14 09:58:03
43阅读
题目大意:如上图所示,已知火车要从A入站,然后从C出站。火车进站的顺序为1~N,现在给你出站的顺序。问:能不能通过
原创 2014-12-09 18:58:08
70阅读
D - RailsCrawling in process...Crawling failedTime Limit:1000MS    Memory Limit:10000KB     64bit IO Format:%I64d & %I64uSubmitStatus Practice POJ 1363 Appoint description:
原创 2022-08-08 17:14:38
73阅读
题意:有n辆车在右边的铁轨上,中间有一短竖着的过渡的铁轨,他们都要开到左边的铁轨上
原创 2022-09-26 10:04:28
34阅读
RailsTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 18846Accepted: 7515DescriptionThere 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
转载 2012-08-02 17:51:00
46阅读
2评论
Description There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately
转载 2016-03-30 21:47:00
55阅读
2评论
RailsTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 18531Accepted: 7391DescriptionThere 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
原创 2021-07-29 16:19:17
76阅读
#include<iostream> #include<stack> using namespace std; int n,target[1001],temp; int main() { while(cin >> n&&n) { while(cin >> temp&&temp) { stack<int> s; int A = 1,B = 1; //A是有顺序的车厢号,B是栈堆指针 target[1] = temp; for(int i = 2;i <= n;++i) { cin >>
转载 2011-07-18 00:01:00
36阅读
2评论
思路和上面的那一题 【杭电】[1022]Tr...
转载 2016-03-04 23:08:00
47阅读
此题纯模拟也能过……   我更懒,直接记栈尾元素和已出元素……Program P1363;var n,i:longint; a:array[1..1000] of longint; b:array[0..1000] of boolean; t:longint; tag:boolean;begin read(n); while (n>0)
原创 2012-08-22 21:09:08
22阅读
模拟题
转载 2011-07-04 09:30:00
42阅读
2评论
Ray. Country there is i
原创 2022-08-24 11:36:03
48阅读
USACO又卡住了T_T...好郁闷...找了到水题来娱乐娱乐..   位置为1)..那么弹栈并且移动输出队列的指针(往后移一位,既++)直到输出队列指针位置的数与栈顶的数不相等~~1~N
原创 2022-08-12 12:57:58
23阅读
题目链接:http://poj.org/problem?id=1363 (lrj白书习题)题目大意:判断一个出栈序列能不能从1,2,3,……,n 经过栈处理后生成。思路: Ⅰ:定理:出栈序列不合法 <=> 存在k,满足i<j<k,使得S[k]<S[i]<S[j]。(i,j,k是入站顺序,s[i],s[j],s[k]是出栈顺序)。 如果用这个定理判断则需要O(n^3)的时间,不合适。 Ⅱ:模拟即可:模拟入栈,①如果当前要进栈的元素是下一个要出栈元素则直接让他入栈出栈就行了,跳到下一个。 ②如果当前栈顶元素是下一个要出栈元素则让它出栈。 ...
转载 2012-11-17 20:23:00
110阅读
2评论
题目链接:http://poj.org/problem?id=1363 (lrj白书习题)题目大意:判断一个出栈序列能不能从1,2,3,……,n 经过栈处理后生成。思路:Ⅰ:定理:出栈序列不合法 存在k,满足i>n){ if (n == 0) break; while...
转载 2012-11-17 12:23:00
49阅读
2评论
题目链接:http://poj.org/problem?id=1363 (lrj白书习题)题目大意:判断一个出栈序列能不能从1,2,3,……,n 经过栈处理后生成。思路:Ⅰ:定理:出栈序列不合法 存在k,满足i>n){ if (n == 0) break; while...
转载 2012-11-17 12:23:00
73阅读
2评论
2100年,ACM牌巧克力将风靡全球。 “绿的,橘红的,棕色的,红的…”,彩色的糖衣可能是ACM巧克力最吸引人的地方。你一共见过多少种颜色?现在,据说ACM公司从一个24种颜色的调色板中选择颜色来装饰他们的美味巧克力。 有一天,Sandy用一大包有五种颜色的巧克力玩了一个游戏。每次他从包里拿出一粒巧
转载 2017-03-05 22:11:00
101阅读
2评论
  • 1
  • 2
  • 3
  • 4
  • 5