A1125 | [COCI-2007_2008-contest5]#1 AVOGADRO
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Luka is slacking again during chemistry class, while the teacher is explaining Avogadro's law.
Luka first drew a table consisting of 3 rows and N columns. Then he wrote the numbers 1 to N into the first row in arbitrary order, each number appearing exactly once. In the other two rows he also wrote integers between 1 and N, but didn't care how many times a number appeared.
Luka can now delete any set of columns from the table. After doing so, he sorts the numbers in each row in ascending order.
He wants to obtain a table in which all three rows are identical after sorting. Write a program that determines the smallest number of columns he must delete.
Luka first drew a table consisting of 3 rows and N columns. Then he wrote the numbers 1 to N into the first row in arbitrary order, each number appearing exactly once. In the other two rows he also wrote integers between 1 and N, but didn't care how many times a number appeared.
Luka can now delete any set of columns from the table. After doing so, he sorts the numbers in each row in ascending order.
He wants to obtain a table in which all three rows are identical after sorting. Write a program that determines the smallest number of columns he must delete.
输入格式
The first line of input contains the integer N (1 ≤ N ≤ 100000), the number of columns in the table.
The following three lines contain N integers each, separated by single spaces. The numbers will be between 1 and N, and there will be no duplicates in the first row.
The following three lines contain N integers each, separated by single spaces. The numbers will be between 1 and N, and there will be no duplicates in the first row.
输出格式
Output the smallest number of columns Luka must delete.
输入输出样例
输入 #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
In test cases worth 40% of points, N will be less than 100.
In test cases worth 70% of points, N will be less than 10000.
In the first example, Luka needs to delete the second, fourth, sixth and seventh columns. After deleting
the columns and sorting each row, all three rows contain the numbers 1, 3 and 5.
In test cases worth 70% of points, N will be less than 10000.
In the first example, Luka needs to delete the second, fourth, sixth and seventh columns. After deleting
the columns and sorting each row, all three rows contain the numbers 1, 3 and 5.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted