QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#5457. 涂色网格

统计

Grammy 有一面由 $n \times m$ 个小方格组成的墙。每个小方格都是单位大小,且必须被完全涂成一种颜色。她想把墙涂成黑白两色。Grammy 喜欢多样性的概念,因此她决定让每一行都与之前的所有行不同,并且每一列也与之前的所有列不同。当她准备开始涂色时,她发现她的颜料刚好够用——白色颜料和黑色颜料各占一半,每种颜色的涂抹面积恰好为 $\frac{nm}{2}$ 个单位面积。请帮助 Grammy 在有限的颜料下满足她的多样性条件。

输入格式

输入包含多个测试用例。 第一行包含一个整数 $T$ ($1 \le T \le 2000$),表示测试用例的数量。 对于每个测试用例: 唯一的一行包含两个整数 $n, m$ ($1 \le n, m \le 1000$)。保证所有测试用例的 $nm$ 之和不超过 $10^6$。

输出格式

对于每个测试用例,如果不存在解决方案,输出 “NO”。否则,输出 “YES”,随后输出 $n$ 行。每行应包含 $m$ 个字符。其中 0 表示白色方格,1 表示黑色方格。

样例

输入 1

5
1 1
2 2
2 4
4 4
5 10

输出 1

NO
YES
10
01
YES
1100
0110
YES
1100
0110
0000
1111
YES
1111100000
0101010101
0011011001
0000111110
1111000001

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.