首页 > 试题广场 >

校赛-A:Valid Pop Sequence

[问答题]

题目标题:

校赛-A:Valid Pop Sequence

题目描述:

In computer science, a stack is a last in, first out (LIFO) abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by two fundamental operations, called push and pop. The push operation adds a new item to the top of the stack.

Assume k integers is pushing into a stack in increasing order 1, 2, …, k. Please write a program that decides whether it is a valid pop sequence. For example, pushing 1, 2, 3 into a stack, (1, 2, 3) and (3, 2, 1) is a valid pop sequence, but (3, 1, 2) isn’t.

输入描述:

The input consists of several test cases.

For each test case, one integer k (1 <= k <= 100000) is given in the first line.

Second line contains k integers, presenting a pop sequence.

输出描述:

If the pop sequence is valid, print a line contains My Dearest. Otherwise it contains

样式输入:

3

1 2 3

3

3 1 2

样式输出:

My Dearest

The Everlasting Guilty Crown

这道题你会答吗?花几分钟告诉大家答案吧!