QOJ.ac

QOJ

実行時間制限: 4 s メモリ制限: 512 MB 満点: 100

#14393. 团

統計

在图论中,如果无向图的一个子图中任意两个节点之间都存在一条边,则称该子图为一个团(clique)。考虑一个含有 $n$ 个节点的无向图 $G$。我们希望将 $G$ 修改为一个新图,使得新图的每个连通分量都是一个团。每次修改操作可以是插入一条新边,或者是删除一条已存在的边。

输入格式

输入的第一行包含一个整数 $t$,表示测试数据的组数。

对于每组测试数据,第一行包含一个整数 $n$ ($1 \le n \le 100$),表示无向图 $G$ 的节点数。

接下来的 $n$ 行,每行包含 $n$ 个整数,对应图 $G$ 的邻接矩阵,其中 $1$ 表示存在边,$0$ 表示不存在边。

输出格式

对于每组测试数据,首先输出样例所示的测试点编号。在冒号后面应该有一个空格。

然后,如果图 $G$ 可以通过不超过 $10$ 步修改为一个新图,则输出所需的最少修改步数;否则输出 $-1$。

样例

输入样例 1

2
7
0 1 1 0 0 0 0
1 0 1 1 0 0 0
1 1 0 1 0 0 0
0 1 1 0 1 0 0
0 0 0 1 0 1 1
0 0 0 0 1 0 1
0 0 0 0 1 1 0
1
0

输出样例 1

Case #1: 2
Case #2: 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.