Universal Cup Judging System

Universal Cup

Limite de temps : 2.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

Building a reliable and efficient reactor consists of many stages, and you are tasked with helping to design such a reactor.

There is a framework representing a grid of size $n \times m$. Some of its cells contain load-bearing walls for the strength of the structure and cannot be used for any other purposes. The remaining cells can be filled with fuel rods and cooling elements, at most one per cell.

According to safety regulations, each fuel rod must be adjacent to at least one cooling element. Formally, their cells must share a common side.

The more fuel rods there are in the design, the more energy can be extracted from the reactor. Your task is to find any configuration with the maximum number of fuel rods while adhering to all the requirements.

Input

The first line contains two integers $n$ and $m$ ($1 \le n \le 12, 1 \le m \le 30$): the height and width of the reactor framework.

Each of the next $n$ lines contains $m$ characters describing the reactor cells. The character . corresponds to a free cell, while the character # corresponds to a load-bearing wall.

Output

Output $nm$ characters, with $m$ characters in each of the $n$ lines that denote an optimal arrangement of the reactor elements. The characters can take the following values:

  • # if there is a load-bearing wall in the cell;
  • 0 if you placed a fuel rod in the cell;
  • 1 if you placed a cooling element in the cell;
  • . if the cell remains empty.

If there are multiple optimal solutions, output any of them.

Example

Sample Input 1

6 9
.........
.........
....#....
....#....
.........
.........

Sample Output 1

001000100
100010001
0010#0100
0010#0100
100010001
001000100

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.