QOJ.ac

QOJ

時間限制: 5 s 記憶體限制: 256 MB 總分: 100

#8432. 黑白棋盘

统计

给定一个大小为 $n \times m$ 的棋盘。棋盘的颜色被涂成黑白相间,使得单元格 $(1, 1)$ 为白色,且任意两个相邻的单元格颜色不同。棋盘上的一些单元格被禁止使用。

你的任务是在棋盘上找到一个连通的图形,该图形不包含任何被禁止的单元格,且恰好包含 $w$ 个白色单元格和 $b$ 个黑色单元格。如果两个单元格共享一条边,则称它们是相邻的。

输入格式

第一行包含三个整数 $n, m$ 和 $k$ ($1 \le n, m \le 10, 0 \le k \le n \cdot m$),分别表示棋盘的行数、列数以及被禁止的单元格数量。

接下来的 $k$ 行包含被禁止单元格的坐标。每行包含一对整数 $x_i$ 和 $y_i$ ($1 \le x_i \le n, 1 \le y_i \le m$),表示一个被禁止单元格的坐标。所有被禁止的单元格互不相同。

最后一行包含两个整数 $w$ 和 $b$ ($0 \le w, b \le n \cdot m, w + b > 0$)。

输出格式

如果无法找到一个不包含被禁止单元格且包含 $w$ 个白色单元格和 $b$ 个黑色单元格的连通图形,则输出一行 “:-(”(不含引号)。

否则,输出 $n$ 行,每行包含 $m$ 个字符,用于描述该图形。这些行必须由字符 “O”、“X” 和 “.” 组成:

  • 字符 “O” 表示图形中包含的一个白色单元格,
  • 字符 “X” 表示图形中包含的一个黑色单元格,
  • 字符 “.” 表示图形中不包含的单元格。

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

样例

输入格式 1

3 4 2
2 2
2 3

输出格式 1

....
X..O
OXOX

输入格式 2

8 10 1
1 5
1 9

输出格式 2

..........
..X...XOX.
..O...O...
..XO.OXO..
..O.O.O.O.
.OXOXOXOXO
..O.O.O.O.
..........

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.