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.