CF1102B.Array K-Coloring
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a consisting of n integer numbers.
You have to color this array in k colors in such a way that:
- Each element of the array should be colored in some color;
- For each i from 1 to k there should be at least one element colored in the i -th color in the array;
- For each i from 1 to k all elements colored in the i -th color should be distinct.
Obviously, such coloring might be impossible. In this case, print "NO". Otherwise print "YES" and any coloring (i.e. numbers c1,c2,…cn , where 1≤ci≤k and ci is the color of the i -th element of the given array) satisfying the conditions above. If there are multiple answers, you can print any.
输入格式
The first line of the input contains two integers n and k ( 1≤k≤n≤5000 ) — the length of the array a and the number of colors, respectively.
The second line of the input contains n integers a1,a2,…,an ( 1≤ai≤5000 ) — elements of the array a .
输出格式
If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers c1,c2,…cn , where 1≤ci≤k and ci is the color of the i -th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can print any.
输入输出样例
输入#1
4 2 1 2 2 3
输出#1
YES 1 1 2 2
输入#2
5 2 3 2 1 2 3
输出#2
YES 2 1 1 2 1
输入#3
5 2 2 1 1 2 1
输出#3
NO
说明/提示
In the first example the answer 2 1 2 1 is also acceptable.
In the second example the answer 1 1 1 2 2 is also acceptable.
There exist other acceptable answers for both examples.