#P10692. [SNCPC2024] 表达式矩阵
[SNCPC2024] 表达式矩阵
Problem Description
An character matrix is called a valid expression matrix if and only if it satisfies the following conditions.
-
The matrix contains only the characters '1', '+', and '*'.
-
The string formed by each row from left to right is a valid expression.
-
The string formed by each column from top to bottom is a valid expression.
The weight of a valid expression matrix is defined as follows: evaluate all expressions formed by each row (left to right) and each column (top to bottom), and take the sum of their values.
Find, among all valid expression matrices, one with the minimum weight. If there are multiple minimum answers, you may output any one of them.
We define a string to be a valid expression as follows.
-
If $s = \overbrace{111\dots111}^{\text{at least one }1}$, then is a valid expression.
-
If both and are valid expressions, then * is also a valid expression.
-
If both and are valid expressions, then + is also a valid expression.
Input Format
The input consists of one line with two integers (), separated by a space, representing the number of rows and columns of the matrix.
Output Format
Output lines, each containing characters. The -th character of the -th line is , representing a matrix with the minimum weight.
If there are multiple minimum answers, you may output any one of them.
4 4
1111
1*11
11*1
1111
Hint
For the sample, the weight of the matrix is . It can be proven that there is no matrix with a smaller weight.
Translated by ChatGPT 5