Ivo is in a square matrix of \(n\) rows and \(n\) columns where \(n\) is an odd number and
holds a magic brush of thickness \(k\). All cells of the matrix are marked with the
symbol ".", and Ivo is in the central cell of the matrix.
Ivo has received a string of instructions, a word consisting of uppercase letters
of the alphabet where each letter represents one instruction. He executes the
instructions in order and does the following depending on the current instruction:
• L - Ivo moves one cell to the left
• R - Ivo moves one cell to the right
• U - Ivo moves one cell up
• D - Ivo moves one cell down
• If the current character is any other letter of the alphabet, Ivo does not
change his position. Instead, he paints all the cells of the matrix that a\(re * le\)ss than \(k\) cells away
from his current position with the current color, regardless of whether they have already been
painted in another color.
If Ivo moves outside the matrix, he will skip that step and continue executing the subsequent instructions.
Your task is to print the appearance of the matrix after Ivo has executed all the instructions.
*The distance between two cells of a matrix is the minimum number of moves needed to get from one cell
to the other, with movement allowed in four directions (up, down, left, right).
The first line contains the natural numbers n, k (\(1 \le n\), \(k \le 50\)), from the text of the task.
The second line contains a word consisting of uppercase letters of the English alphabet. The length of the
word will be less than or equal to 50.
In \(n\) lines, print \(n\) characters per line, the appearance of the matrix after Ivo executes all the instructions.
| 서브태스크 | 점수 | 설명 |
|---|---|---|
1 | 2점 | \(n = 1\) |
2 | 10점 | \(k = 1\) |
3 | 15점 | \(k = 2\) |
4 | 23점 | No additional constraints. |
1 1
ALURDFF3 2
LUUADDRCRBAA.
ACB
CBBClarification of the first example:
Ivo will never move from the only cell of the matrix and will only paint that cell. After executing all the
instructions, that cell is colored in color F.