Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Sequence
Description Given a sequence, { A_{1 }> A_{2}, ..., A, you are to cut it into three sub-sequences and reverse them separately to form a new one which is the smallest possible sequence in alphabet order. _{n}The alphabet order is defined as follows: for two sequence { B_{1}, B_{2}, ..., B}, we say {_{n}A_{1}, A_{2}, ..., A} is smaller than {_{n}B_{1}, B_{2}, ..., B} if and only if there exists such _{n}i ( 1 ≤ i ≤ n) so that we have A < _{i}B = _{i and }A_{j}B for each _{j}j < i.Input The first line contains The following Output output Sample Input 5 10 1 2 3 4 Sample Output 1 10 2 4 3 Hint {10, 1, 2, 3, 4} -> {10, 1 | 2 | 3, 4} -> {1, 10, 2, 4, 3} Source POJ Founder Monthly Contest – 2008.04.13, Yao Jinyu |

[Submit] [Go Back] [Status] [Discuss]

Any problem, Please Contact Administrator