欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1530B.Putting Plates
Putting Plates
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 and width , divided into cells. Let denote the cell in the -th row and the -th column of the rectangle (; ).
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 you put a plate into, at least one of the following conditions must be satisfied: , , , .
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 contains a plate, you can't put plates into cells , , , , , , , .
Put as many plates on the table as possible without violating the rules above.
Input
The first line contains a single integer () — the number of test cases.
Each of the following lines describes one test case and contains two integers and () — the height and the width of the table.
Output
For each test case, print lines containing characters each. Character in line must be equal to if you are putting a plate into cell , and 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.
Note
For the first test case, example output contains the only way to put plates on the table.
For the second test case, there are many ways to put plates on the table, example output contains one of them.
Putting more than plates in the first test case or more than plates in the second test case is impossible.
Samples
3
3 5
4 4
5 6
10101
00000
10101
0100
0001
1000
0010
010101
000000
100001
000000
101010
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |