QOJ.ac

QOJ

时间限制: 3.0 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#9936. 海棠与排名

统计

在本题中,排名不存在平局(即排名应当是 $1 \sim n$ 的一个排列)。 $n$ 名选手参加了两场比赛。在每场比赛中,第 $i$ 名选手的排名分别为 $a_i$ 和 $b_i$。 dXqwq 从 Haitang 那里得到了一个总排名,其中第 $i$ 名选手的排名为 $c_i$。 显然,如果一名选手在两场比赛中的排名都高于另一名选手,那么他的总排名也应该更高。dXqwq 希望你检查 $c$ 是否满足这一条件。 由于 dXqwq 在排名中发现了矛盾,Haitang 进行了 $m$ 次操作。在每次操作中,给定两个整数 $x, y$,Haitang 将交换 $c_x, c_y$。你需要确定在每次操作后,$c$ 是否满足上述条件。 注意,操作不是独立的。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 10^5$),分别表示排列的长度和询问次数。 第二行包含 $n$ 个整数 $a_i$ ($1 \le a_i \le n$),表示排列 $a$。 第三行包含 $n$ 个整数 $b_i$ ($1 \le b_i \le n$),表示排列 $b$。 第四行包含 $n$ 个整数 $c_i$ ($1 \le c_i \le n$),表示排列 $c$。 接下来的 $m$ 行,每行包含两个整数 $x$ 和 $y$ ($1 \le x, y \le n$),表示一次操作。

输出格式

在每次操作后,如果排名满足条件,输出 “Yes”,否则输出 “No”。

样例

输入 1

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

输出 1

No
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.