POJ1363 Rails中英文对照翻译与参考解答

该博客介绍了POJ1363题目的详细解析,涉及一列火车在PopPush城车站如何通过车厢重新排列来满足特定顺序的要求。问题通过栈来模拟火车车厢的进出,判断是否能按给定顺序重组车厢。博客提供了输入输出样例,源比赛及参考代码。
摘要由CSDN通过智能技术生成

传送门: POJ1363
关键词: 栈;

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. Moreover, it turned out that the station could be only a dead-end one (see picture) and due to lack of available space it could have only one track.

PopPush城有一个著名的、建于上个世纪的铁路。PopPush城的乡村山多到难以置信。不幸的是,资金在那个时候非常有限。仅仅可以建路面铁轨。此外,事实证明该站可能只是一个死胡同(见图),由于缺乏可用空间,它可能只有一个铁轨。

Rails

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.

当地传统的火车方向是从A方向到达的每一列火车都继续朝B方向行驶,车厢可以以某种方式重组。假设从A方向到达的火车具有N<=1000个车厢,这些车厢以递增的顺序1,2,…,N编号。负责车厢调度的工作人员需要知道能否使它以a1,a2,…,aN的顺序从B方向驶出。请你帮他写一个程序,用来判断能否得到指定的车厢顺序。你可以假定在进入车站之前每节车厢之间都是不连着的,并且它们可以自行移动,直到处在B方向的铁轨上。另外假定车站里可以停放任意多节的车厢。但是一旦车厢进入车站,它就不能再回到A方向的铁轨上了,并且一旦它进入B方向的铁轨后,它就不能再回到车站。

Input

The input consists of blocks of lines. Each block except the last describes o

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值