#P7935. [COCI 2007/2008 #5] AVOGADRO

    ID: 8962 远端评测题 1000ms 32MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>模拟2007枚举队列COCI(克罗地亚)

[COCI 2007/2008 #5] AVOGADRO

Problem Description

Luka drew a table with 33 rows and NN columns, and then wrote the integers from 11 to NN into the table. In the first row, each integer appears exactly once. In the other two rows, each number may appear any number of times, or not appear at all.

Luka may now delete any number of columns. After that, he sorts each row of the table in increasing order.

He wants to obtain a table such that, after sorting in increasing order, the three rows are exactly the same. Please find the minimum number of columns he needs to delete.

Input Format

The first line contains an integer NN, which is the number of columns in the table.

The next three lines each contain NN integers. These integers are all between 11 and NN. In the first row, each number appears once and only once.

Output Format

One line containing an integer, the minimum number of columns Luka needs to delete.

7
5 4 3 2 1 6 7
5 5 1 1 3 4 7
3 7 1 4 5 6 2 
4
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

Hint

For 40%40\% of the testdata, N100N \le 100.

For 70%70\% of the testdata, N10000N \le 10000.

For 100%100\% of the testdata, 1N1051 \le N \le 10^5.

Sample 1 Explanation:

For Sample 1, Luka needs to delete the 2nd, 4th, 6th, and 7th columns. After deleting and sorting, all three rows contain only the three integers 1,3,51, 3, 5.

The score for this problem follows the original contest settings, with a full score of 6060 points.

Translated by ChatGPT 5