A10954 | Till I Collapse
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Rick and Morty want to find MR. PBH and they can't do it alone. So they need of Mr. Meeseeks. They Have generated $n$ Mr. Meeseeks, standing in a line numbered from $1$ to $n$ . Each of them has his own color. $i$ -th Mr. Meeseeks' color is $a_{i}$ .
Rick and Morty are gathering their army and they want to divide Mr. Meeseeks into some squads. They don't want their squads to be too colorful, so each squad should have Mr. Meeseeks of at most $k$ different colors. Also each squad should be a continuous subarray of Mr. Meeseeks in the line. Meaning that for each $1<=i<=e<=j<=n$ , if Mr. Meeseeks number $i$ and Mr. Meeseeks number $j$ are in the same squad then Mr. Meeseeks number $e$ should be in that same squad.
Also, each squad needs its own presidio, and building a presidio needs money, so they want the total number of squads to be minimized.
Rick and Morty haven't finalized the exact value of $k$ , so in order to choose it, for each $k$ between $1$ and $n$ (inclusive) need to know the minimum number of presidios needed.
Rick and Morty are gathering their army and they want to divide Mr. Meeseeks into some squads. They don't want their squads to be too colorful, so each squad should have Mr. Meeseeks of at most $k$ different colors. Also each squad should be a continuous subarray of Mr. Meeseeks in the line. Meaning that for each $1<=i<=e<=j<=n$ , if Mr. Meeseeks number $i$ and Mr. Meeseeks number $j$ are in the same squad then Mr. Meeseeks number $e$ should be in that same squad.
Also, each squad needs its own presidio, and building a presidio needs money, so they want the total number of squads to be minimized.
Rick and Morty haven't finalized the exact value of $k$ , so in order to choose it, for each $k$ between $1$ and $n$ (inclusive) need to know the minimum number of presidios needed.
输入格式
The first line of input contains a single integer $n$ ( $1<=n<=10^{5}$ ) — number of Mr. Meeseeks.
The second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ separated by spaces ( $1<=a_{i}<=n$ ) — colors of Mr. Meeseeks in order they standing in a line.
The second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ separated by spaces ( $1<=a_{i}<=n$ ) — colors of Mr. Meeseeks in order they standing in a line.
输出格式
In the first and only line of input print $n$ integers separated by spaces. $i$ -th integer should be the minimum number of presidios needed if the value of $k$ is $i$ .
输入输出样例
输入 #1
5 1 3 4 3 3
输出 #1
4 2 1 1 1
输入 #2
8 1 5 7 8 1 7 6 1
输出 #2
8 4 3 2 1 1 1 1
For the first sample testcase, some optimal ways of dividing army into squads for each $k$ are:
1. $[1],[3],[4],[3,3]$
2. $[1],[3,4,3,3]$
3. $[1,3,4,3,3]$
4. $[1,3,4,3,3]$
5. $[1,3,4,3,3]$
For the second testcase, some optimal ways of dividing army into squads for each $k$ are:
1. $[1],[5],[7],[8],[1],[7],[6],[1]$
2. $[1,5],[7,8],[1,7],[6,1]$
3. $[1,5,7],[8],[1,7,6,1]$
4. $[1,5,7,8],[1,7,6,1]$
5. $[1,5,7,8,1,7,6,1]$
6. $[1,5,7,8,1,7,6,1]$
7. $[1,5,7,8,1,7,6,1]$
8. $[1,5,7,8,1,7,6,1]$
1. $[1],[3],[4],[3,3]$
2. $[1],[3,4,3,3]$
3. $[1,3,4,3,3]$
4. $[1,3,4,3,3]$
5. $[1,3,4,3,3]$
For the second testcase, some optimal ways of dividing army into squads for each $k$ are:
1. $[1],[5],[7],[8],[1],[7],[6],[1]$
2. $[1,5],[7,8],[1,7],[6,1]$
3. $[1,5,7],[8],[1,7,6,1]$
4. $[1,5,7,8],[1,7,6,1]$
5. $[1,5,7,8,1,7,6,1]$
6. $[1,5,7,8,1,7,6,1]$
7. $[1,5,7,8,1,7,6,1]$
8. $[1,5,7,8,1,7,6,1]$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted