#T630. 画圣诞树
画圣诞树
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:

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 is constant starting from the second row); 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 two 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 * characters like the one in the figure, where each row consists of several consecutive * characters.
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 several lines. The first line contains an integer n, representing 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 has already indicated that the Christmas tree consists of two parts: A and B. Therefore, the drawing of the graphic should be considered in two parts. Both parts A and B require consideration of the graphic's axis of symmetry. Thus, the entire problem can be broken down into three subproblems:
(1) Determine the axis of symmetry; (2) Draw part A; (3) Draw part B.
【Problem Analysis】
Analysis of subproblem 1: If the row with the most * characters has m *s, then the column number of the axis of symmetry for 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 a single segment of the tree. This smaller problem is related to loops, 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 *s. 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