308495: CF1530B. Putting Plates
Memory Limit:512 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Putting Plates
题意翻译
#### 1、题目描述翻译 有一张桌子,分为 $h$ 行 $w$ 列。 桌子**边缘**上的某一行某一列可以放一个盘子(也可以不放)。但是,一个盘子的上面、下面、左面、右面、左上、右上、左下、右下都不能有盘子。 问题来了:这个桌子,放盘子最多的方案是什么?请输出这个方案。当然,答案不止一种,你也不用全部输出,输出任意一个,即可。 #### 2、输入格式翻译 第一行一个数 $t$($1\le t\le100$),表示测试数据组数。 接下来 $t$ 行,每行两个数,分别代表 $h$ 和 $w$($3\le h,w\le20$)。 #### 3、输出格式翻译 输出这个桌子放盘子最多的方案。盘子用 `1` 表示,空位用 `0` 表示。 每个测试数据之间都要打印一个空行。 Translated by [dengzijun](https://www.luogu.com.cn/user/387836)题目描述
To celebrate your birthday you have prepared a festive table! Now you want to seat as many guests as possible. The table can be represented as a rectangle with height $ h $ and width $ w $ , divided into $ h \times w $ cells. Let $ (i, j) $ denote the cell in the $ i $ -th row and the $ j $ -th column of the rectangle ( $ 1 \le i \le h $ ; $ 1 \le j \le w $ ). Into each cell of the table you can either put a plate or keep it empty. As each guest has to be seated next to their plate, you can only put plates on the edge of the table — into the first or the last row of the rectangle, or into the first or the last column. Formally, for each cell $ (i, j) $ you put a plate into, at least one of the following conditions must be satisfied: $ i = 1 $ , $ i = h $ , $ j = 1 $ , $ j = w $ . To make the guests comfortable, no two plates must be put into cells that have a common side or corner. In other words, if cell $ (i, j) $ contains a plate, you can't put plates into cells $ (i - 1, j) $ , $ (i, j - 1) $ , $ (i + 1, j) $ , $ (i, j + 1) $ , $ (i - 1, j - 1) $ , $ (i - 1, j + 1) $ , $ (i + 1, j - 1) $ , $ (i + 1, j + 1) $ . Put as many plates on the table as possible without violating the rules above.输入输出格式
输入格式
The first line contains a single integer $ t $ ( $ 1 \le t \le 100 $ ) — the number of test cases. Each of the following $ t $ lines describes one test case and contains two integers $ h $ and $ w $ ( $ 3 \le h, w \le 20 $ ) — the height and the width of the table.
输出格式
For each test case, print $ h $ lines containing $ w $ characters each. Character $ j $ in line $ i $ must be equal to $ 1 $ if you are putting a plate into cell $ (i, j) $ , and $ 0 $ otherwise. If there are multiple answers, print any. All plates must be put on the edge of the table. No two plates can be put into cells that have a common side or corner. The number of plates put on the table under these conditions must be as large as possible. You are allowed to print additional empty lines.
输入输出样例
输入样例 #1
3
3 5
4 4
5 6
输出样例 #1
10101
00000
10101
0100
0001
1000
0010
010101
000000
100001
000000
101010