Universal Cup Judging System

Universal Cup

Süre Sınırı: 2 s Bellek Sınırı: 1024 MB
İstatistikler

VegiCat 有一个 $n \times n$ 的整数矩阵 $A = (a_{ij})$。对于每个 $1 \le i, j \le n$:

  • 如果 $i = j$、$i = 1$ 或 $j = 1$,则 $a_{ij} = -1$。
  • 否则,$a_{ij}$ 是一个非负整数。

请帮助 VegiCat 构造一个包含 $n$ 个顶点的无向简单图 $G$,顶点编号从 $1$ 到 $n$。

对于每一对满足 $i > 1$ 且 $j > 1$ 的不同顶点 $i, j$,该图都必须满足以下条件:在删除顶点 $i$ 和 $j$ 以及所有以这两个顶点之一为端点的边之后,恰好剩下 $a_{ij}$ 条边。

problem_23598_b8dedf72b88f4e039a232880f532fc20.png

每一对顶点 $i, j$ 是分别独立考虑的。也就是说,对于每一对顶点,都从尚未删除任何顶点或边的原图 $G$ 开始。

保证至少存在一个满足条件的图。如果存在多种解,输出任意一种即可。

输入格式

第一行包含一个整数 $T$($1 \le T \le 6 \cdot 10^4$),表示测试数据的组数。接下来是各组测试数据的描述。

对于每组测试数据,第一行包含一个整数 $n$($4 \le n \le 10^3$),表示图中的顶点数。

接下来的 $n$ 行中,每行包含 $n$ 个用空格分隔的整数 $a_{ij}$($-1 \le a_{ij} \le \frac{(n-3)(n-2)}{2}$),表示题面中描述的矩阵 $A$。

保证所有测试数据中 $n^2$ 的总和不超过 $1.2 \cdot 10^6$,且至少存在一个与矩阵 $A$ 对应的图。

输出格式

对于每组测试数据,输出你所构造的图的邻接矩阵。输出 $n$ 行,每行包含 $n$ 个用空格分隔的整数。每个整数必须为 $0$ 或 $1$。如果顶点 $i$ 与顶点 $j$ 之间存在一条边,则第 $i$ 行第 $j$ 列的元素为 $1$,否则为 $0$。如果存在多种解,输出任意一种即可。

样例

输入格式 1

2
5
-1 -1 -1 -1 -1
-1 -1  3  1  2
-1  3 -1  2  2
-1  1  2 -1  1
-1  2  2  1 -1
7
-1 -1 -1 -1 -1 -1 -1
-1 -1  4  5  3  6  5
-1  4 -1  5  4  5  5
-1  5  5 -1  5  7  5
-1  3  4  5 -1  4  4
-1  6  5  7  4 -1  5
-1  5  5  5  4  5 -1

输出格式 1

0 1 0 1 1
1 0 0 0 0
0 0 0 1 0
1 0 1 0 1
1 0 0 1 0
0 1 1 0 1 0 0
1 0 0 0 0 1 1
1 0 0 0 1 0 1
0 0 0 0 1 1 0
1 0 1 1 0 0 1
0 1 0 1 0 0 0
0 1 1 0 1 0 0

说明

实际输入矩阵中两个整数之间只有一个空格。样例中额外的空格是为了增强排版的易读性。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.