51 atcoder#ARC138D. [ARC138D] Differ by K bits

[ARC138D] Differ by K bits

Score : 700700 points

Problem Statement

You are given integers NN and KK. Determine whether there exists a permutation P=(P0,P1,,P2N1)P=(P_0,P_1,\cdots,P_{2^N-1}) of (0,1,,2N1)(0,1,\cdots,2^N-1) satisfying the condition below, and construct one such sequence if it exists. Note that PP is 00-indexed.

  • For every ii (0i2N10 \leq i \leq 2^N-1), PiP_i and Pi+1mod2NP_{i+1 \mod 2^N} differ by exactly KK bits in binary representation. The comparison is made after zero-padding both integers to NN bits.

Constraints

  • 1KN181 \leq K \leq N \leq 18
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

Output

If there is no PP satisfying the condition, print No. If there is such a PP, print it in the following format:

Yes

P0P_0 P1P_1 \cdots P2N1P_{2^N-1}

If there are multiple solutions satisfying the condition, printing any of them will be accepted.

3 1
Yes
0 1 3 2 6 7 5 4

Here, we have P=(000,001,011,010,110,111,101,100)P=(000,001,011,010,110,111,101,100) in binary representation.

We can see that P1=001P_1=001 and P2=011P_2=011, for example, differ by exactly 11 bit, satisfying the condition for i=1i=1. The same goes for every ii.

2 2
No