QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#1893. 友好的车

Statistics

车是国际象棋中的一种棋子。它可以在水平或垂直方向上移动任意数量的空格,且不能跳过其他棋子。如果其他棋子与车在同一垂直或水平线上,车就可以吃掉该棋子。棋盘上的每个方格内最多只能放置一个车。

给定 $k$ 个车和一个 $n \times m$ 的棋盘。你需要将这些车放置在棋盘上,使得它们互不攻击。

输入格式

输入仅一行,包含三个整数 $n, m$ 和 $k$ —— 棋盘的边长以及车的数量 ($1 \le n, m, k \le 100$)。

输出格式

如果无法在 $n \times m$ 的棋盘上放置 $k$ 个车,输出 Impossible

如果至少存在一种正确的放置方案,输出 Possible。然后输出 $n$ 行,每行 $m$ 个字符 —— 描述棋盘上车的放置情况。第 $i$ 行的第 $j$ 个字符如果是 “*”,表示方格 $(i, j)$ 放置了一个车;如果是 “.”,则表示该方格为空。

如果存在多种正确的放置方案,输出其中任意一种即可。

样例

输入 1

1 2 1

输出 1

Possible
*.

输入 2

3 3 100

输出 2

Impossible

输入 3

3 5 2

输出 3

Possible
..*..
.....
*....

说明

第三个测试用例中车的放置示意图:

红色标记了左下角的车可以攻击的方格,蓝色标记了右上角的车可以攻击的方格,紫色标记了两个车都可以攻击的方格。

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.