CF1487C.Minimum Ties

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A big football championship will occur soon! nn teams will compete in it, and each pair of teams will play exactly one game against each other.

There are two possible outcomes of a game:

  • the game may result in a tie, then both teams get 11 point;
  • one team might win in a game, then the winning team gets 33 points and the losing team gets 00 points.

The score of a team is the number of points it gained during all games that it played.

You are interested in a hypothetical situation when all teams get the same score at the end of the championship. A simple example of that situation is when all games result in ties, but you want to minimize the number of ties as well.

Your task is to describe a situation (choose the result of each game) so that all teams get the same score, and the number of ties is the minimum possible.

输入格式

The first line contains one integer tt ( 1t1001 \le t \le 100 ) — the number of test cases.

Then the test cases follow. Each test case is described by one line containing one integer nn ( 2n1002 \le n \le 100 ) — the number of teams.

输出格式

For each test case, print n(n1)2\frac{n(n - 1)}{2} integers describing the results of the games in the following order: the first integer should correspond to the match between team 11 and team 22 , the second — between team 11 and team 33 , then 11 and 44 , ..., 11 and nn , 22 and 33 , 22 and 44 , ..., 22 and nn , and so on, until the game between the team n1n - 1 and the team nn .

The integer corresponding to the game between the team xx and the team yy should be 11 if xx wins, 1-1 if yy wins, or 00 if the game results in a tie.

All teams should get the same score, and the number of ties should be the minimum possible. If there are multiple optimal answers, print any of them. It can be shown that there always exists a way to make all teams have the same score.

输入输出样例

  • 输入#1

    2
    2
    3

    输出#1

    0 
    1 -1 1

说明/提示

In the first test case of the example, both teams get 11 point since the game between them is a tie.

In the second test case of the example, team 11 defeats team 22 (team 11 gets 33 points), team 11 loses to team 33 (team 33 gets 33 points), and team 22 wins against team 33 (team 22 gets 33 points).

首页