#P7935. [COCI 2007/2008 #5] AVOGADRO
[COCI 2007/2008 #5] AVOGADRO
Problem Description
Luka drew a table with rows and columns, and then wrote the integers from to 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 , which is the number of columns in the table.
The next three lines each contain integers. These integers are all between and . 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 of the testdata, .
For of the testdata, .
For of the testdata, .
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 .
The score for this problem follows the original contest settings, with a full score of points.
Translated by ChatGPT 5