QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#9666. L-覆盖

Statistiques

给定一个 $n$ 行 $m$ 列的网格,行号从上到下为 $1$ 到 $n$,列号从左到右为 $1$ 到 $m$。现在有无限多个 $1+1$ L 型瓷砖(如下图所示),你需要使用这些瓷砖覆盖网格,使得只有第 $1$ 行第 $m$ 列的单元格(位于右上角)不被覆盖,而其他每个单元格都被且仅被一个瓷砖覆盖。你需要判断是否可以实现满足这些条件的覆盖,如果可以,输出一种覆盖方案。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 10^4$),表示测试用例的数量。

对于每个测试用例,有一行包含两个整数 $n, m$ ($2 \le n, m \le 500$),表示要覆盖的网格大小。

保证所有测试用例的 $n \times m$ 之和不超过 $10^6$。

输出格式

对于每个测试用例,如果无法实现满足条件的覆盖,则输出一行 No

否则,首先输出一行 Yes,然后输出 $n$ 行,每行包含一个长度为 $m$ 的字符串,表示一种覆盖方案。字符串仅包含六个字符 UDLRC.。第 $i$ 行的第 $j$ 个字符表示网格中第 $i$ 行第 $j$ 列单元格的覆盖情况。字符 . 表示未被覆盖的单元格。对于输出的覆盖方案,应该只有一个 . 位于第 $1$ 行第 $m$ 列。字符 C 表示瓷砖的中心(即瓷砖的左下角)。字符 UDLR 分别表示该单元格的上方、下方、左方、右方单元格被该瓷砖的中心覆盖。你需要确保除了右上角的单元格,每个单元格都被且仅被一个瓷砖覆盖。

样例

样例输入 1

2
4 4
2 3

样例输出 1

Yes
CLD.
UDCL
DCLD
CLRC
No

说明

对于第一个测试用例,一种可能的覆盖方案如下图所示。

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.