atcoder#ARC131E. [ARC131E] Christmas Wreath

[ARC131E] Christmas Wreath

Score : 600600 points

Problem Statement

Takahashi has Christmas decoration consisting of NN balls and N(N1)2\frac{N(N-1)}{2} ropes. The balls are numbered 11 to NN, and for any two different balls, there is exactly one rope that connects them.

He decides to light up each rope in red, blue, or white.

For better appearance, he wants to satisfy all of the following conditions.

Condition 1 the numbers of ropes lighted in red, blue, and white are all equal.

Condition 2 there is no triple of integers a,b,ca, b, c (1a<b<cN)(1 \leq a < b < c \leq N) such that all of the following three ropes have different colors:

  • the rope connecting aa and bb,
  • the rope connecting bb and cc,
  • the rope connecting aa and cc.

Create a way to light up the ropes to satisfy the conditions. If there is no such way, report so.

Constraints

  • 3N503 \leq N \leq 50
  • NN is an integer.

Input

Input is given from Standard Input in the following format:

NN

Output

If there is no way to light up the ropes to satisfy the conditions, print No.

If such a way exists, print it in the following format:

Yes

c1,2c_{1,2}c1,3c_{1,3}c1,4c_{1,4}\ldotsc1,Nc_{1,N}

c2,3c_{2,3}c2,4c_{2,4}\ldotsc2,Nc_{2,N}

::

cN1,Nc_{N-1,N}

Here, the character ci,jc_{i, j} (1i<jN)(1 \leq i < j \leq N) should be the following:

  • ci,j=c_{i, j} = R when lighting up the rope connecting Balls ii and jj red,
  • ci,j=c_{i, j} = B when lighting up the rope connecting Balls ii and jj blue,
  • ci,j=c_{i, j} = W when lighting up the rope connecting Balls ii and jj white.
4
No

For N=4N=4, there is no way to light up the ropes to satisfy the conditions, so the output No is correct.

Below is an example of an output in the Yes case, which is incorrect in this case. This is because, for (a,b,c)=(1,2,3)(a, b, c) = (1, 2, 3) in Condition 2, the rope connecting a,ba, b is red, the rope connecting b,cb, c is white, and the rope connecting a,ca, c is blue, all of which have different colors.

Yes
RBW
WB
R