QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 2048 MB Total points: 100

#15624. U-Shaped Panels

الإحصائيات

你家后院有一个矩形池塘。由于池塘的长和宽都是一米的整数倍,因此可以将池塘看作由若干一平方米的区域组成。

你总觉得池塘太大了,想要用谷仓里的面板覆盖其中的一些区域。这些面板的大小和形状完全相同,由排列成 U 型的一平方米木板组成。面板的整体尺寸为 $k$ 米乘 $k$ 米,在正方形的三条边上共有 $3k - 2$ 块木板。其余的 $(k - 2) \times (k - 1)$ 矩形区域是空的。图 H.1 展示了一个大小为 $k = 5$ 的面板。

图 H.1. 大小为 $k = 5$ 的面板(左)及其俯视图(右)

你计划用这些面板覆盖池塘中特定的区域,其余部分保持不覆盖。放置面板时,必须确保每一块木板恰好覆盖一个区域。只要满足此条件,面板的方向可以任意选择。面板之间不能重叠,也不能超出池塘范围。

请判断你的计划是否可行。

输入格式

输入包含一个或多个测试用例。第一行包含一个整数 $t$ ($1 \le t \le 10$),表示测试用例的数量。接下来是 $t$ 个测试用例的描述,每个测试用例的格式如下:

$n$ $m$ $k$ $s_1$ $\vdots$ $s_n$

第一行包含三个整数 $n$、$m$ 和 $k$。整数 $n$ 和 $m$ 分别表示池塘的长和宽 ($5 \le n \le 1000$, $5 \le m \le 1000$)。整数 $k$ 表示 U 型面板的大小 ($5 \le k \le 1000$)。接下来的 $n$ 行表示你的计划。其中第 $i$ 行包含一个长度为 $m$ 的字符串 $s_i$,由字符 '#' 和 '.' 组成。如果一个一平方米的区域位于距离前边缘 $r - 1$ 到 $r$ 米、距离左边缘 $c - 1$ 到 $c$ 米之间,则称该区域位于 $(r, c)$。对于每个 $i$ 和 $j$,如果 $s_i$ 的第 $j$ 个字符是 '#',则 $(i, j)$ 处的区域必须被面板的木板完全覆盖。否则,该区域应保持完全不被覆盖。

所有测试用例中 $n$ 的总和不超过 1000,$m$ 的总和也满足相同限制。

输出格式

对于每个测试用例,如果计划可行,输出 yes;否则输出 no

样例

输入 1

1
10 10 5
..........
..........
....#####.
..#.#.#.#.
..#.#.#.#.
..#.#.#.#.
..#.#.#.#.
..#####...
..........
..........

输出 1

yes

输入 2

2
5 21 5
.#...##...###....##..
.#..#..#..#..#..#..#.
.#..#.....###...#....
.#..#..#..#.....#..#.
.#...##...#......##..
6 14 6
.############.
.#..........#.
.#..........#.
.#..........#.
.#..........#.
.############.

输出 2

no
yes

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.