QOJ.ac

QOJ

时间限制: 2 s 内存限制: 512 MB 总分: 100

#886. 语言

统计

在 Askinavia,有三种语言:Arwegian、Banish 和 Cwedish。Askinavia 由一个 $n \times m$ 的网格组成,每个单元格中至少有一种语言。已知这三种语言中的每一种都在一个非空的连通单元格集合中被使用。“连通”意味着可以通过移动到相邻单元格(共享一条边的两个单元格)在任意两个单元格之间往返。

你进行了一项调查,以找出 Askinavia 中每种语言的使用地点。以下问题被发送到了该地区的每个单元格:“请指出在您的单元格中是否使用了一种或多种语言”。但由于印刷错误,问题后面没有选项,所以每个人只写了“one”(一种)或“several”(多种)。因此,你唯一知道的是每个单元格中究竟是只使用了一种语言,还是使用了不止一种语言。

为了充分利用现有情况,你需要找到任何一种符合该信息的这三种语言的划分方式。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 200$)。

接下来的 $n$ 行,每行包含一个长度为 $m$ 的字符串,由字符 12 组成。第 $i$ 行的第 $j$ 个字符如果是 1,表示该单元格中恰好使用了一种语言;如果是 2,表示该单元格中至少使用了两种语言。

输出格式

如果语言可以根据已知信息进行划分,则输出三份网格。第一份网格应由字符 A. 组成,其中 A 表示 Arwegian 在该单元格中使用,. 表示不使用。接下来的两份网格应分别由字符 B.,以及 C. 组成,分别对应 Banish 和 Cwedish 的相关信息。

请记住,这三个区域必须是连通且非空的,并且每个单元格都必须属于某个区域。为了可读性,建议在三个网格之间留出空行,但这并非必须。如果存在多种解,输出其中任意一个即可。

否则,如果没有办法划分这些语言,输出 impossible

样例

输入 1

3 4
2211
1112
1112

输出 1

AAAA
...A
....
BB..
BBBB
...B
....
...C
CCCC

输入 2

1 1
1

输出 2

impossible

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.