QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 32 MB Total points: 60

#17123. 阿伏伽德罗

Statistics

Luka 又在化学课上开小差了,此时老师正在讲解阿伏伽德罗定律。

Luka 首先画了一个包含 $3$ 行和 $N$ 列的表格。然后,他将数字 $1$ 到 $N$ 以任意顺序填入第一行,每个数字恰好出现一次。在另外两行中,他也填入了介于 $1$ 到 $N$ 之间的整数,但他并不在意每个数字出现的次数。

Luka 现在可以从表格中删除任意数量的列。删除之后,他将每一行中的数字按升序排序。

他希望在排序后,这三行数字完全相同。请编写一个程序,确定他最少需要删除多少列。

输入格式

第一行包含一个整数 $N$ ($1 \le N \le 100\,000$),表示表格的列数。

接下来的三行,每行包含 $N$ 个整数,两两之间用单个空格分隔。这些数字都在 $1$ 到 $N$ 之间,且第一行中不会有重复的数字。

输出格式

输出 Luka 最少需要删除的列数。

子任务

  • 对于 $40\%$ 的测试数据,满足 $N < 100$。
  • 对于 $70\%$ 的测试数据,满足 $N < 10\,000$。

样例

输入样例 1

7
5 4 3 2 1 6 7
5 5 1 1 3 4 7
3 7 1 4 5 6 2

输出样例 1

4

输入样例 2

9
1 3 5 9 8 6 2 4 7
2 1 5 6 4 9 3 4 7
3 5 1 9 8 6 2 8 7

输出样例 2

2

说明

在第一个样例中,Luka 需要删除第二、第四、第六和第七列。删除这些列并对每一行进行排序后,所有三行都包含数字 $1$、$3$ 和 $5$。

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.