当前位置:网站首页>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的顺序输入 能否输出你输入的那种序列
边栏推荐
- L2-026 小字辈 (25 分)
- L2-027 名人堂与代金券 (25 分)
- Camera calibration toobox for Matlab(一)—— 工具包的基本使用
- [In-depth study of 4G/5G/6G topic-54]: L3 signaling control-3-segmentation of software functions and processes-signaling of CU-UP network elements
- glide4入门
- L2-016 愿天下有情人都是失散多年的兄妹 (25 分)
- DSPE-PEG-Biotin,385437-57-0,磷脂-聚乙二醇-生物素用于生物分子的检测和纯化
- 迁移学习(Transfer Learning)的背景、历史
- Qt——获取文件夹下所有子文件名称
- Are Huishang Futures official and reliable?Is it safe to open an account in Huishang Futures?
猜你喜欢
随机推荐
一、搭建django自动化平台(实现一键执行sql)
Superficial understanding of ports
leetcode:295. 数据流的中位数
poj1961 Period(KMP)
mysql中模糊查询的四种用法介绍
徽商期货正规可靠吗?在徽商期货开户是否安全?
openGauss社区七月运作报告
L2-023 图着色问题 (25 分)
L2-015 互评成绩 (25 分)
字节一面:TCP 和 UDP 可以使用同一个端口吗?
3531. 哈夫曼树
转载,fragment讲的很好的大佬
Subject: Ordered Queue
R文件找不到问题
C人脸识别
差分约束做法
对于端口的粗浅理解
Regular use in js
R file not found problem
C1. Pokémon Army (easy version)