CF1102B.Array K-Coloring

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array aa consisting of nn integer numbers.

You have to color this array in kk colors in such a way that:

  • Each element of the array should be colored in some color;
  • For each ii from 11 to kk there should be at least one element colored in the ii -th color in the array;
  • For each ii from 11 to kk all elements colored in the ii -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,cnc_1, c_2, \dots c_n , where 1cik1 \le c_i \le k and cic_i is the color of the ii -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 nn and kk ( 1kn50001 \le k \le n \le 5000 ) — the length of the array aa and the number of colors, respectively.

The second line of the input contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai50001 \le a_i \le 5000 ) — elements of the array aa .

输出格式

If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers c1,c2,cnc_1, c_2, \dots c_n , where 1cik1 \le c_i \le k and cic_i is the color of the ii -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 12~ 1~ 2~ 1 is also acceptable.

In the second example the answer 1 1 1 2 21~ 1~ 1~ 2~ 2 is also acceptable.

There exist other acceptable answers for both examples.

首页