407876: GYM102911 L L Textiles

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. L Textilestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

The Philippines is home to more than 175 ethnolinguistic groups, with many indigenous peoples still carrying on their heritage through traditions which are hundreds of years old. Among these traditions is the weaving of fabric and textiles adorned with intricate geometric patterns which reflect the rich history and philosophies of the various indigenous peoples throughout the country.

Bob, inspired by these patterns, decided to create geometric patterns of his own, which he decided to call "L-Textiles". Of course, he is not skilled in weaving or even embroidery, so he will plan out his design on the computer first.

The fabric where the pattern is to be placed can be represented as a $$$2^N \times 2^N$$$ square unit grid. Bob envisions that the pattern with primarily consist of many L-shaped pieces which consist of three adjacent unit squares, all of the same color, in the shape of an "L" (see picture). The pieces can be rotated. Bob's L-shaped pieces come in 26 different colors, and he has an infinite amount of each color of piece.

Unfortunately, Bob realized that it is always impossible to completely cover the $$$2^N \times 2^N$$$ grid using only L-shaped tiles because its area (in square units) will never be divisible by 3. To fix this, he blacked out the $$$1 \times 1$$$ square located at $$$(x,y)$$$ (the square in the $$$x$$$th row from the top and the $$$y$$$th column from the left). Now, Bob desires to create a pattern that satisfies the following.

  • The entire mural is completely covered by the L-shaped pieces, except the square at $$$(x,y)$$$.
  • Only the L-shaped pieces are used
  • The L-shaped pieces do not overlap and the L-shaped pieces cannot be broken into smaller pieces.
  • No two touching L-shaped pieces in the finished pattern may be of the same color. Two pieces are considered "touching" if they share an edge in common (it's okay for them to touch at corners).

Bob has already made some patterns of his own, but now he challenges you to make some too! Of course, if the task is impossible, you must tell Bob that he made a mistake.

To aid in creating your pattern, you may download the following app.

Then, run the app by entering java -jar L-Painter.jar in the command line/terminal. You need to have a Java Runtime Environment of 8 or higher downloaded in order to use the app.Input

The first line of input contains a single integer $$$N$$$.

The second line of input contains two space-separated integers $$$x$$$ and $$$y$$$.

Output

If the task is impossible, output NO on a single line. Otherwise, output YES.

If YES, output $$$2^N$$$ more lines, each containing a string with $$$2^N$$$ characters. The $$$y$$$th character of the $$$x$$$th line should be the hash character #. Each other character must be an upper case English letter, representing the color of some L-shaped piece. An L-shaped piece is represented by three touching characters on the grid that are the same letter, in an L-shape. Two L-shaped pieces are considered the same color if (and only if) they are represented by the same letter.

Scoring

$$$1 \leq N \leq 8$$$

$$$1 \leq x,y \leq 2^N$$$

Subtask 1 (20 points):

$$$N \leq 1$$$

Subtask 2 (15 points):

$$$N \leq 2$$$

Subtask 3 (15 points):

$$$N \leq 3$$$

Subtask 4 (15 points):

$$$N \leq 4$$$

Subtask 5 (20 points):

$$$x = y = 1$$$

Subtask 6 (15 points):

No further constraints.

ExamplesInput
2
1 3
Output
YES
CC#A
CBAA
ABBC
AACC
Input
3
5 7
Output
YES
AABBCCBB
ADBAACAB
DDCADDAA
AACCADBB
CADAAB#B
CCDDBBAA
BAABAABA
BBABBABB
Note

Here is Bob's pattern for the first sample test case.

Here is Bob's pattern for the second sample test case.

加入题单

算法标签: