一道把我坑了的简单水题。
不知道为什么深究了,而且弄不清,一直到凌晨,现在北京时间1.14——留作纪念。
其实那个先对比还是挺巧妙地。
如果a和b[]不等的话,压栈,相等的话再看栈是不是为空,不空则弹栈,如果空的话直接进入下个比较。
不多说,下面都有注释。
————————————————————————————————————————
题目:Rails
Rails
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 31401 Accepted: 12201
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 i