欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1734B.Bright, Nice, Brilliant
Bright, Nice, Brilliant
There is a pyramid which consists of floors. The floors are numbered from top to bottom in increasing order. In the pyramid, the -th floor consists of rooms.
Denote the -th room on the -th floor as . For all positive integers and such that , there are one-way staircases which lead from to and from to respectively.
In each room you can either put a torch or leave it empty. Define the brightness of a room to be the number of rooms with a torch from which you can reach the room through a non-negative number of staircases.
For example, when and torches are placed in the rooms , , , , , and , the pyramid can be illustrated as follows:

In the above picture, rooms with torches are colored in yellow, and empty rooms are white. The blue numbers in the bottom-right corner indicate the brightness of the rooms.
The room (the room with a star) has brightness . In the picture below, the rooms from where you can reach have red border. The brightness is since there are three torches among these rooms.

The pyramid is called nice if and only if for all floors, all rooms in the floor have the same brightness.
Define the brilliance of a nice pyramid to be the sum of brightness over the rooms , , , ..., .
Find an arrangement of torches in the pyramid, such that the resulting pyramid is nice and its brilliance is maximized.
We can show that an answer always exists. If there are multiple answers, output any one of them.
Input
The first line of the input contains a single integer () — the number of test cases. The description of the test cases follows.
The only line of each test case contains a single positive integer () — the number of floors in the pyramid.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output lines, the arrangement of torches in the pyramid.
The -th line should contain integers, each separated with a space. The -th integer on the -th line should be if room has a torch, and otherwise.
We can show that an answer always exists. If there are multiple answers, output any one of them.
Note
In the third test case, torches are placed in , , , , and .

The pyramid is nice as rooms on each floor have the same brightness. For example, all rooms on the third floor have brightness .
The brilliance of the pyramid is . It can be shown that no arrangements with will have a greater brilliance.
Samples
3
1
2
3
1
1
1 1
1
1 1
1 0 1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |