当前位置:网站首页>poj1363 Rails(栈模拟)
poj1363 Rails(栈模拟)
2022-08-08 17:25:00 【51CTO】
D - Rails
Crawling in process...
Crawling failed
Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u
Submit Status Practice POJ 1363
System Crawler (2016-05-09)
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.
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.
Input
The input consists of blocks of lines. Each block except the last describes one train and possibly more requirements for its reorganization. In the first line of the block there is the integer N described above. In each of the next lines of the block there is a permutation of 1, 2, ..., N. The last line of the block contains just 0.
The last block consists of just one line containing 0.
Output
The output contains the lines corresponding to the lines with permutations in the input. A line of the output contains Yes if it is possible to marshal the coaches in the order required on the corresponding line of the input. Otherwise it contains No. In addition, there is one empty line after the lines corresponding to one block of the input. There is no line in the output corresponding to the last ``null'' block of the input.
Sample Input
Sample Output
读题读了好久。。。
大概题意就是问你 按照1.......n的顺序输入 能否输出你输入的那种序列
边栏推荐
猜你喜欢
转载,fragment讲的很好的大佬
LeetCode_Binary Tree_Medium_515. Find the maximum value in each tree row
DSPE-PEG-NH2,DSPE-PEG-amine,474922-26-4,磷脂-聚乙二醇-氨基科研试剂
字节一面:TCP 和 UDP 可以使用同一个端口吗?
VISTA无人驾驶模拟器;FinRL量化金融深度强化学习库;『深度神经网络应用』电子书;CUDA/TensorRT案例集锦;前沿论文 | ShowMeAI资讯日报
【20210923】Choose the research direction you are interested in?
MySQL 表的增删查改
The difference between a uri (url urn)
yarn : 无法加载文件 D:xxx\node_global\yarn.ps1 因为在此系统上禁止运行脚本
【LeetCode】Exam Summary: Depth-First Search (DFS)
随机推荐
Cholesterol-PEG-DBCO,CLS-PEG-DBCO,胆固醇-聚乙二醇-二苯基环辛炔一种环炔烃
10 种最佳 IDE 软件 ,你更忠爱哪一个?
Cy5反式环辛烯,TCO-Cy5,Cy5 trans-cyclooctene标记生物分子
C语言中变量在内存中的保存与访问
软件工程基础知识--认识软件工程
dp, dpi, px knowledge supplement
【数学模型】灰色关联分析
MySQL database
KITTI数据集简介(一)—— 传感器介绍
测试/开发程序员停滞不前,倦怠怎么办?突破各种失败和挫折......
LeetCode_Backtrack_Medium_491. Incrementing Subsequence
C语言每日一练——Day01:求最大公约数(三种方法)
咸阳广发证券股票开户安全吗,需要准备什么证件
The difference between B+ tree and B- tree
顺序表与链表结构及解析
Tensorflow教程(二)——基本概念与搭建流程
The difference between rv and sv
L2-024 部落 (25 分)(并查集)
activemq 消息头、消息体、消息属性
中金证券股票开户流程是什么,我需要准备身份证吗,安全吗