UVa 514

From Algorithmist
Jump to navigation Jump to search

514 - Rails[edit]

Summary[edit]

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.

Explanation[edit]

The problem requires reordering items on a stack, specifically to determine if the reordering can be done in a single pass.

Gotchas[edit]

Notes[edit]

Implementations[edit]

Optimizations[edit]

Input[edit]

5
1 2 3 4 5
5 4 1 2 3
0
6
6 5 4 3 2 1
0
0

Output[edit]

Yes
No

Yes

References[edit]

  1. Reference 1

Categories here, use the form [[Category:UVa Online Judge|514]] [[Category: Category Name]], see Categories for a list