atcoder#AGC059D. [AGC059D] Distinct Elements on Subsegments

[AGC059D] Distinct Elements on Subsegments

Score : 11001100 points

Problem Statement

For an integer array A=(A1,A2,,AN+K1)A=(A_1, A_2, \ldots, A_{N + K-1}) (1AiN+K11 \leq A_i \leq N+K-1), let's construct an array B=(B1,B2,,BN)B=(B_1, B_2, \ldots, B_N), where BiB_i is the number of distinct elements in Ai,Ai+1,,Ai+K1A_i,A_{i+1},\ldots,A_{i+K-1}.

You are given B1,B2,,BNB_1, B_2, \ldots, B_N. Determine if there exists an array AA which could have produced such an array BB, and if yes, construct one.

Solve TT test cases for each input file.

Constraints

  • 1T51041 \le T \le 5 \cdot 10^4
  • 2N21052 \le N \le 2 \cdot 10^5
  • 2K21052 \le K \le 2 \cdot 10^5
  • 1BiK1 \le B_i \le K
  • The sum of NN in one input file doesn't exceed 21052\cdot 10^5.
  • The sum of KK in one input file doesn't exceed 21052\cdot 10^5.
  • All values in the input are integers.

Input

Input is given from Standard Input in the following format:

TT

case1case_1

case2case_2

\vdots

caseTcase_T

Each case is in the following format:

NN KK

B1B_1 B2B_2 \ldots BNB_N

Output

For each test case, if such an array AA doesn't exist, output NO.

Otherwise, output the answer in the following format:

YES

A1A_1 A2A_2 \ldots AN+K1A_{N+K-1}

Here, 1AiN+K11 \leq A_i \leq N+K-1 must hold, and AA should produce BB. If multiple solutions exist, any of them will be accepted.

In printing YES or NO, you can output each letter in any case (upper or lower).

3
3 3
1 2 1
4 3
1 2 2 1
6 4
3 3 3 3 3 3
NO
YES
1 1 1 2 2 2 
YES
1 2 3 1 2 3 1 2 3