QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#5466. 排列压缩

统计

Grammy 拥有一个长度为 $n$ 的排列。她想要删除排列中一些无用的元素,因此她决定使用一些魔法工具来删除它们。共有 $k$ 个魔法工具,其中第 $i$ 个工具可以删除长度恰好为 $l_i$ 的区间中的最大元素。每个魔法工具最多只能使用一次。

在使用工具之前,Grammy 向你展示了她删除后的数组蓝图。新数组由 $1$ 到 $n$ 之间恰好 $m$ 个不同的元素组成。请帮助 Grammy 判断是否可以通过使用这些魔法工具删除元素得到该数组。

输入格式

输入包含多组测试数据。第一行包含一个整数 $T$ ($1 \le T \le 10^5$),表示测试数据的组数。

对于每组测试数据: 第一行包含 3 个整数 $n, m, k$ ($1 \le m \le n \le 2 \times 10^5, 1 \le k \le 2 \times 10^5$),分别表示排列的长度、压缩后数组的长度以及魔法工具的参数。 第二行包含 $n$ 个不同的整数 $a_i$ ($1 \le a_i \le n$),表示初始排列。保证元素互不相同。 第三行包含 $m$ 个不同的整数 $b_i$ ($1 \le b_i \le n$),表示压缩后的数组。保证元素互不相同。 第四行包含 $k$ 个整数 $l_i$ ($1 \le l_i \le n$),表示魔法工具。

保证 $\sum n \le 2 \times 10^5$ 且 $\sum k \le 2 \times 10^5$。

输出格式

对于每组测试数据,输出 "YES" 或 "NO",表示该问题的答案。

样例

输入 1

3
5 2 3
5 1 3 2 4
5 2
1 2 4
5 5 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
3 2 2
3 1 2
3 2
2 3

输出 1

YES
YES
NO

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.