#B4124. Draw a Right Arrow
Draw a Right Arrow
Draw a Right Arrow
A right arrow is composed by splicing a horizontal bar (a rectangle) and a rightward isosceles triangle. The overall figure is vertically symmetric. In the upper half of the triangle, the first row occupies $1$ cell, the second row occupies $2$ cells, and so on. Specifically, the arrow is drawn in an $n\times m$ grid such that:
- The horizontal bar has a height of $k$ and appears in the middle of the arrow.
- The remaining top and bottom parts (each of height $t=\frac{n-k}{2}$) display the triangle. In these parts, the triangle portion occupies a fixed block of width $B$ on the right. In the top triangle part the $i$th row (starting from $0$) has $(i+1)$ '#' characters (left‐aligned in the block) and the rest of the block is filled with dots. The bottom triangle part is the vertical mirror of the top.
- The horizontal bar rows (from row $t$ to row $t+k-1$) are drawn by splicing a left rectangle and the triangle block. In these rows, the left part (of fixed width $L$) is filled with '#' characters, while the triangle block is drawn in a way that its number of '#' characters is $B$ on the middle horizontal bar row and $B-1$ on the other horizontal bar rows. Here, the values $L$ and $B$ are determined by the formulas:
$L = m - (k+1)$ and $B = m - L = k+1$.
For example, when n = 7
, m = 10
, and k = 3
, we have $t=2$, $L=10-(3+1)=6$, and $B=4$, and the arrow will look like:
......#... ......##.. #########. ########## #########. ......##.. ......#...
Given three integers n
, m
, and k
, draw the right arrow according to the above rules.
inputFormat
The input consists of three space‐separated integers:
n
: the number of rows of the grid (an odd integer).m
: the number of columns of the grid.k
: the height of the horizontal bar (an odd integer less than n).
outputFormat
Output the drawn arrow pattern consisting of n
lines and m
columns. Use the character '#' to represent a filled cell and '.' to represent an empty cell.
sample
7 10 3
......#...
......##..
#########.
##########
#########.
......##..
......#...
</p>