QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 64 MB Total points: 100

#23716. Logo

Statistics

In the coming year 20XX, the International Omatsuri in Informatics will be held in Japan. In preparation for the event, you have been assigned to design the logo for this festival.

Every time, the logo of the International Omatsuri in Informatics is created based on a certain fixed picture. This picture consists of several cells chosen from a rectangular grid of square cells with $W$ columns horizontally and $H$ rows vertically. This time, you have decided to color this picture in red and white, the colors of the Japanese national flag, to make the logo. To keep the coloring work simple, only $1$ color can be used for $1$ cell.

To decide how to color the cells, you asked a designer friend for advice. According to his wonderful aesthetic sense, it is desirable that both the region painted red and the region painted white form line-symmetric figures. Furthermore, considering color balance, he also told you that the number of cells painted red should be $K$. Since he did not tell you a coloring that satisfies these conditions, you need to find one yourself. Given the picture and the value of $K$, write a program to find $1$ coloring that satisfies the conditions.

Input

On line $1$, $3$ integers $W, H, K$ ($1 \le W \le 40$, $1 \le H \le 40$, $1 \le K \le WH - 1$) are written separated by spaces. These represent the width and height of the given picture, and the number of cells to be painted red.

The following $H$ lines represent the data of the picture. On line $i + 1$ ($1 \le i \le H$), $W$ integers, each $0$ or $1$, are written separated by spaces. When the $j$-th integer ($1 \le j \le W$) on line $i + 1$ is $1$, it means that the cell at the $i$-th row from the top and $j$-th column from the left is used in the picture; when it is $0$, it means that the cell is not used in the picture. At least $2$ cells are always used in the picture. The value of $K$ is guaranteed to be strictly less than the number of cells used in the picture.

For every input used for grading, there exists at least $1$ coloring that satisfies the conditions.

Output

Output to standard output. Output integers representing the coloring, with $W$ space-separated integers per line across $H$ lines. When the $j$-th integer on line $i$ is $1$, it means the cell at the $i$-th row from the top and $j$-th column from the left is painted red; when it is $2$, it means that cell is painted white. For cells not used in the picture, output $0$.

If multiple colorings are possible, you may output any of them.

Grading Criteria

Among the test data used for grading, $20\%$ of the score satisfies $W, H \le 5$.

Sample Input 1

4 3 2
0 1 0 0
1 0 1 1
1 0 0 0

Sample Output 1

0 2 0 0
1 0 2 1
2 0 0 0

This output corresponds to the following coloring. Gray cells represent cells painted red, and white cells represent cells painted white. The dashed line and the dotted line are the axes of symmetry for the red region and the white region, respectively.

problem_23716_f29f24931b8f41fc37021f4ae1fdfcfe.png

The following colorings do not satisfy the conditions:

problem_23716_18a85da7c1f14d92f4958c79520d922b.png
The red region is not line-symmetric
problem_23716_1a8c14d35eccc4cea02bc0409cbf6510.png
The number of cells painted red is not $2$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.