QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓

#18676. 植树

통계

承妍想要种树。为此,她将在无限网格中选择一些格子撒下树种。树种拥有神秘的力量,受周围树种的影响,会长成苹果树或桃树中的一种。

种子长成什么树遵循以下规则。如果两个共享一条边的格子都有种子,则称这两个种子相邻。相邻种子数为偶数的种子会长成苹果树,而相邻种子数为奇数的种子会长成桃树。

假设承妍如上图种下了 $5$ 个种子。相互相邻的种子如蓝色箭头所示。中间的种子与 $3$ 个种子相邻,因此长成桃树。

最终如上图,会长出 $3$ 棵苹果树和 $2$ 棵桃树。

种植种子时,所有种子必须在网格中连通。也就是说,对于任意两个种子,必须能够仅通过相邻的种子在它们之间移动。例如,下面的布局是不允许的。

承贤想要种 $A$ 棵苹果树和 $B$ 棵桃树。请判断是否可能,如果可能,输出树的布局。

输入格式

第一行给出两个非负整数 $A$ 和 $B$,以空格分隔。($A \geq 0$; $B \geq 0$; $1 \le A+B \le 200$)

输出格式

第一行,若布局可行则输出 YES,否则输出 NO

若可行,第二行输出行数 $R$ 和列数 $C$,以空格分隔。($1 \le R,C \le 200$)

接下来 $R$ 行,每行输出 $C$ 个字符,字符之间无空格。每个字符为 O.,其中 O 表示有种子,. 表示无种子。

样例

输入格式 1

3 2

输出格式 1

YES
3 3
.OO
OOO
...

输入格式 2

1 0

输出格式 2

YES
1 1
O

输入格式 3

7 0

输出格式 3

YES
3 3
.OO
OOO
OO.

输入格式 4

8 0

输出格式 4

YES
4 4
....
.OOO
.O.O
.OOO

输入格式 5

9 0

输出格式 5

NO

输入格式 6

0 7

输出格式 6

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.