文件名称:median1363
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:538byte
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
pku1363,1、题目简介:
给出一个数n,1~n的所有整数会以从小到大的顺序入栈,但出栈顺序不定,同时给出几组出栈的顺序,要求判断给出出栈顺序是否可能。
2、算法实现思想:
首先建立一系列的Stack操作,入push,pop,isEmpty,top,clear等
将要判断的出栈序列存储至一个数组map中。然后从最大的n开始到1进行循环压栈和出栈处理。从出栈序列map[]的尾部开始,进栈,不断寻找最大的出栈,次大的出栈...最后若栈空则为Yes,否则为No
-pku1363.The local tradition is that every train arriving from the direction A continues in the direction B with coaches reorganized in some way. Assume that the train arriving from the direction A has N <= 1000 coaches numbered in increasing order 1, 2, ..., N. The chief for train reorganizations must know whether it is possible to marshal coaches continuing in the direction B so that their order will be a1, a2, ..., aN. Help him and write a program that decides whether it is possible to get the required order of coaches. You can assume that single coaches can be disconnected from the train before they enter the station and that they can move themselves until they are on the track in the direction B. You can also suppose that at any time there can be located as many coaches as necessary in the station. But once a coach has entered the station it cannot return to the track in the direction A and also once it has left the station in the direction B it cannot return back to the station
给出一个数n,1~n的所有整数会以从小到大的顺序入栈,但出栈顺序不定,同时给出几组出栈的顺序,要求判断给出出栈顺序是否可能。
2、算法实现思想:
首先建立一系列的Stack操作,入push,pop,isEmpty,top,clear等
将要判断的出栈序列存储至一个数组map中。然后从最大的n开始到1进行循环压栈和出栈处理。从出栈序列map[]的尾部开始,进栈,不断寻找最大的出栈,次大的出栈...最后若栈空则为Yes,否则为No
-pku1363.The local tradition is that every train arriving from the direction A continues in the direction B with coaches reorganized in some way. Assume that the train arriving from the direction A has N <= 1000 coaches numbered in increasing order 1, 2, ..., N. The chief for train reorganizations must know whether it is possible to marshal coaches continuing in the direction B so that their order will be a1, a2, ..., aN. Help him and write a program that decides whether it is possible to get the required order of coaches. You can assume that single coaches can be disconnected from the train before they enter the station and that they can move themselves until they are on the track in the direction B. You can also suppose that at any time there can be located as many coaches as necessary in the station. But once a coach has entered the station it cannot return to the track in the direction A and also once it has left the station in the direction B it cannot return back to the station
(系统自动生成,下载前可以参看下载内容)
下载文件列表
median1363.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.