QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#12211. 角击

统计

你有一个由 $n \times m$ 个方格组成的矩形棋盘。每个方格中包含一个字符,字符为 “*”、“+” 或 “.”。

三格骨牌(tromino)是由棋盘上的一个方格(称为中心)和另外两个与中心共边的方格组成的图形。如果这两个方格有公共顶点,则该三格骨牌是 L 型的;否则它是 I 型的。

你可以在棋盘上绘制一些互不重叠的三格骨牌。I 型三格骨牌的中心必须包含 “+”。L 型三格骨牌的中心必须包含 “*” 或 “+”。所有三格骨牌的非中心方格必须包含 “.”。

你的目标是绘制尽可能多的互不重叠的三格骨牌。

输入格式

第一行包含两个整数 $n$ 和 $m$:棋盘的行数和列数($2 \le n, m \le 100$)。

接下来的 $n$ 行,每行包含 $m$ 个字符,每个字符为 “*”、“+” 或 “.”。这些行共同描述了棋盘。

输出格式

输出 $n$ 行,每行包含 $m$ 个字符:放置了三格骨牌后的棋盘。如果一个方格属于某个三格骨牌,则输出一个小写英文字母;如果不属于,则输出该方格原有的字符。同一个三格骨牌内的方格必须包含相同的字母。共享边且属于不同三格骨牌的方格必须包含不同的字母。

如果有多种可能的答案,输出其中任意一种即可。

样例

输入 1

2 2
*.
..

输出 1

aa
a.

输入 2

3 3
...
.*.
...

输出 2

.a.
aa.
...

输入 3

5 5
+*..+
..++.
.+.++
.**.+
.+*.+

输出 3

+*baa
.bb+a
ccc++
.**.+
.+*.+

输入 4

11 13
.............
.+++....+++..
....+..+.....
....+..+.....
....+..+.....
.+++....+++..
....+......+.
....+......+.
....+......+.
.+++....+++..
.............

输出 4

.abc....abc..
aabcc..aabcc.
..baaacccb...
...dddeee....
.abfffgggbc..
aab+a..aabcc.
..baa...abaaa
...ccc....ddd
.abddd..abccc
aabee..aabee.
..be.....be..

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#347EditorialOpen题解jiangly2025-12-14 07:14:24View

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.