CF1487C.Minimum Ties

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

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.

一场盛大的足球锦标赛即将举行!共有 nn 支队伍参赛,且每两支队伍之间恰好进行一场比赛。

一场比赛可能有两种结果:

  • 比赛以平局结束,则双方各得 11 分;
  • 一方获胜,则胜方得 33 分,负方得 00 分。

一支队伍的得分等于它在所有比赛中获得的分数总和。

你关注一种假设情形:锦标赛结束后,所有队伍的得分完全相同。一个简单的例子是所有比赛均以平局结束,但你还希望尽可能减少平局场数。

你的任务是:为每场比赛指定结果(胜/负/平),使得所有队伍最终得分相同,且平局场数达到最小可能值。

输入格式

The first line contains one integer tt (1≤t≤1001 \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 (2≤n≤1002 \le n \le 100) — the number of teams.

第一行包含一个整数 tt(1≤t≤1001 \le t \le 100)—— 测试用例的数量。

接下来是各测试用例。每个测试用例由一行描述,该行包含一个整数 nn(2≤n≤1002 \le n \le 100)—— 队伍的数量。

输出格式

For each test case, print n(n−1)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 n−1n - 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.

对于每个测试用例,输出 n(n−1)2\frac{n(n - 1)}{2} 个整数,按如下顺序描述各场比赛结果:第一个整数对应队伍 11 与队伍 22 的比赛,第二个对应队伍 11 与队伍 33 的比赛,接着是 11 与 44、……、11 与 nn、22 与 33、22 与 44、……、22 与 nn,依此类推,直至队伍 n−1n - 1 与队伍 nn 的比赛。

对于队伍 xx 与队伍 yy 之间的比赛,对应的整数应为:若 xx 获胜则为 11,若 yy 获胜则为 −1-1,若平局则为 00。

所有队伍的最终得分必须相同,且平局场数应尽可能少。若存在多种最优解,输出任意一种即可。可以证明,总存在一种方式使得所有队伍得分相同。

输入输出样例

  • 输入#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).

在示例的第一个测试用例中,两支队伍各得 11 分,因为它们之间的比赛以平局结束。

在示例的第二个测试用例中,队伍 11 击败队伍 22(队伍 11 获得 33 分),队伍 11 输给队伍 33(队伍 33 获得 33 分),队伍 22 战胜队伍 33(队伍 22 获得 33 分)。

输入解题思路,AI测评打分。不知道怎么写?

首页