#T427. 画圣诞树

画圣诞树

Description

Christmas is approaching, and many merchants have drawn Christmas tree patterns on their promotional boards, as shown in the figure. A Christmas tree consists of two parts, A and B:

0015.png
Part A is composed of n (n ≥ 1) triangular character matrices, each uniquely determined by three parameters: ai, bi, and ci. Here, ai represents the number of characters in the first row of the matrix; bi represents the difference in the number of characters between each subsequent row and the previous one (bi must be even); and ci indicates the number of rows in the character matrix.

Part B is a rectangle with x rows and y columns, uniquely determined by the parameters x and y.

Since the Christmas tree is axisymmetric, the tree constructed from all the parameters is uniquely determined. Simply put, the Christmas tree we refer to is a matrix of asterisks (*) like the one in the figure, where each row's characters are a series of connected * symbols.


Notes:

(1) The input data ensures the Christmas tree will not exceed the size of a single page.

(2) The Christmas tree must be axisymmetric, and the first column of the character matrix must contain at least one non-space character (i.e., the tree should be "flush left" as much as possible). Under these requirements, the output Christmas tree matrix is guaranteed to be unique (ignoring trailing spaces at the end of each line).

Input Format

The input data consists of multiple lines. The first line is an integer n, indicating the number of character matrices in Part A. The following n lines each contain three positive integers: ai, bi, and ci (ai is odd, bi is even).

The last line of the input contains two positive integers, x and y (y is odd), representing the number of rows and columns in Part B.

Output Format

For the given Christmas tree parameters in the input, output the corresponding Christmas tree matrix.

```input1 3 1 4 3 5 4 3 5 4 4 2 5 ``` ```output1 * ***** ********* ***** ********* ************* ***** ********* ************* ***************** ***** ***** ``` ## Hint

【Problem Analysis】

The problem statement indicates that the Christmas tree consists of two parts: A and B. Therefore, drawing the graphic should be considered in two parts. Both parts A and B need to account for the symmetry axis of the graphic. Thus, the entire problem can be broken down into three subproblems:

(1) Determine the symmetry axis; (2) Draw part A; (3) Draw part B.


【Problem Analysis】

Analysis of subproblem 1: If the row with the most asterisks (*) has m asterisks, then the column number for the symmetry axis of parts A and B should be (m + 1) div 2.

Analysis of subproblem 2: Part A is divided into n segments of the tree, and the printing method for each segment is similar. Therefore, we only need to focus on how to print one segment of the tree. This subproblem is a loop-related issue, which has been studied in loop-structured programming.

Analysis of subproblem 3: Filling part B is relatively straightforward—simply print x rows, each containing y asterisks. Upon deeper analysis, there is a clever approach: part B can actually be treated as a special segment in part A where ai = y, bi = 0, ci = x. Thus, subproblem 3 can also be incorporated into subproblem 2.

At this point, the problem of printing the Christmas tree has been successfully resolved.


【Key Points】Process + Pattern Recognition

Source

CodesOnline