QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#9884. 网格构造

统计

给定正整数 $H$ 和 $W$。你的目标是在坐标平面上使用若干个“U 型”图形绘制一个 $H$ 行 $W$ 列的网格。

执行以下操作可以绘制一个 U 型图形:

  • 选择整数 $1 \le x \le H$ 和 $1 \le y \le W$。
  • 从以下四条线段中,选择任意三条不同的线段:
    • 连接 $(x - 1, y - 1)$ 和 $(x - 1, y)$ 的线段,
    • 连接 $(x - 1, y - 1)$ 和 $(x, y - 1)$ 的线段,
    • 连接 $(x, y)$ 和 $(x - 1, y)$ 的线段,
    • 连接 $(x, y)$ 和 $(x, y - 1)$ 的线段。
  • 在坐标平面上绘制所选的三条线段。

然而,你绘制的线段不得与之前绘制的任何线段共享除端点以外的任何点。

通过重复此操作,是否可以绘制出连接所有满足 $0 \le x \le H$ 和 $0 \le y \le W$ 的网格点的长度为 1 的线段?如果可以,请提供一个示例。

输入格式

输入格式如下:

$H \ W$

  • 所有输入值均为整数。
  • $1 \le H, W \le 1000$

输出格式

如果无法通过重复该操作绘制出网格,输出 No。 如果可以,请按以下格式输出操作序列:

Yes $S_1$ $\vdots$ $S_H$

其中 $S_1, \dots, S_H$ 是长度为 $W$ 的字符串,对于 $S_i$ 的第 $j$ 个字符($1 \le i \le H, 1 \le j \le W$),定义如下:

  • 如果不存在以 $(x, y) = (i, j)$ 为参数的操作,则 $S_i$ 的第 $j$ 个字符为 ‘.’。
  • 否则,存在唯一一个以 $(x, y) = (i, j)$ 为参数的操作。在该操作中:
    • 如果所选的三条线段排除了“连接 $(x - 1, y - 1)$ 和 $(x - 1, y)$ 的线段”,则 $S_i$ 的第 $j$ 个字符为 ‘v’。
    • 如果所选的三条线段排除了“连接 $(x - 1, y - 1)$ 和 $(x, y - 1)$ 的线段”,则 $S_i$ 的第 $j$ 个字符为 ‘>’。
    • 如果所选的三条线段排除了“连接 $(x, y)$ 和 $(x - 1, y)$ 的线段”,则 $S_i$ 的第 $j$ 个字符为 ‘<’。
    • 如果所选的三条线段排除了“连接 $(x, y)$ 和 $(x, y - 1)$ 的线段”,则 $S_i$ 的第 $j$ 个字符为 ‘^’。

注意:评测系统对 Yes 和 No 的大小写不敏感。 请参考样例输入和可视化工具以获取进一步说明。

样例

样例输入 1

3 3

样例输出 1

Yes
<<^
v.^
v>>

样例输入 2

4 4

样例输出 2

No

样例输入 3

4 5

样例输出 3

No

说明

你可以从本题的“附件”中下载可视化工具。 在第一个样例中,如图所示,你可以通过绘制 U 型图形来绘制一个 $3 \times 3$ 的网格。注意,在对应中心单元格的位置没有绘制 U 型图形。(为了清晰起见,图中对 U 型图形进行了着色,但这与题目本身无关。)

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.