I. 2023秋-A-2 Two Ways In, One Way Out

    传统题 400ms 64MiB

2023秋-A-2 Two Ways In, One Way Out

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

题目描述

Consider a special queue which is a linear structure that allows insertions at both ends, yet deletions at one end. Your job is to check, for a given insertion sequence, if a deletion sequence is possible. For example, if we insert 1, 2, 3, 4, and 5 in order, then it is possible to obtain 1, 3, 2, 5, and 4 as an output, but impossible to obtain 5, 1, 3, 2, and 4.

输入格式

Each input file contains one test case.

For each case, the first line gives 2 positive integers NN and KK (10\le 10), which are the number of insertions and the number of queries, respectively. Then NN distinct numbers (each no larger than 10610^6) are given in the next line, as the insertion sequence.

Finally KK lines follow, each contains NN inserted numbers as the deletion sequence to be checked.

All the numbers in a line are separated by spaces.

输出格式

For each deletion sequence, print in a line yes if it is indeed possible to be obtained, or no otherwise.

样例

5 4
10 2 3 4 5
10 3 2 5 4
5 10 3 2 4
2 3 10 4 5
3 5 10 4 2
yes
no
yes
no

限制

Java (javac) 时间限制 550 ms 内存限制 512 MB

其他编译器 时间限制 400 ms 内存限制 64 MB

PAT2023秋季重现赛

未参加
状态
已结束
规则
IOI
题目
11
开始于
2025-8-31 14:00
结束于
2025-8-31 17:30
持续时间
3.5 小时
主持人
参赛人数
37