1051. Pop Sequence (25)
时间限制
100 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
Given a stack which can keep M numbers at most. Push N numbers inthe order of1, 2, 3, ..., N and pop randomly. You are supposed to tell ifa given sequence of numbers is a possible pop sequence ofthe stack. For example, if M is 5and N is 7, we can obtain 1, 2, 3, 4, 5, 6, 7fromthe stack, but not3, 2, 1, 7, 5, 6, 4.
Input Specification:
Each input filecontainsone test case. For eachcase, thefirstlinecontains3 numbers (all no more than 1000): M (the maximum capacity ofthe stack), N (thelengthof push sequence), and K (thenumberof pop sequences to be checked). Then K lines follow, eachcontainsa pop sequence of N numbers. All the numbers inaline are separated byaspace.
Output Specification:
For each pop sequence, print inoneline"YES"ifit is indeed a possible pop sequence ofthe stack, or"NO"ifnot.
Sample Input:
57512345673217564765432156437211765432
Sample Output:
YES
NO
NO
YES
NO
题目1051. Pop Sequence (25)时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop rando