QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100

#15648. Network Topology in Hezardastan

统计

Hezardastan 是伊朗领先的信息技术集团,拥有一个庞大的数据中心,其中包含 $n$ 台服务器和 $m$ 个终端(其中 $m \le n$)。终端是由键盘和显示器组成的一套设备,可以连接到服务器进行管理。服务器的编号为 $1$ 到 $n$,终端的编号为 $1$ 到 $m$。该数据中心具有特定的网络拓扑结构,其中并非每个终端都一定能连接到每台服务器。例如,下图展示了 3 个终端和 6 台服务器的情况,如果终端与服务器之间连有线,则表示该终端可以连接到该服务器。

如果服务器的一个大小为 $m$ 的子集 $S$ 可以被这些终端同时管理,即每个终端都可以连接到 $S$ 中一个不同的服务器,则称该子集 $S$ 是可管理的(manageable)。例如,在上述例子中,子集 $\{2, 3, 6\}$ 是可管理的,因为其成员可以分别由终端 $\{1, 2, 3\}$ 管理。如果一个服务器子集的大小为 $m$ 且不是可管理的,则称其为不可管理的(unmanageable)。如果一个网络拓扑不存在任何不可管理的服务器子集(即所有大小为 $m$ 的服务器子集都是可管理的),则称该网络拓扑是完全可管理的(totally manageable)。例如,上图所示的网络拓扑是完全可管理的;但如果断开终端 2 与服务器 5 之间的连接,它就不再是完全可管理的,因为子集 $\{1, 5, 6\}$、$\{2, 5, 6\}$、$\{3, 5, 6\}$ 和 $\{4, 5, 6\}$ 将变得不可管理。给定数据中心的网络拓扑,你需要判断它是完全可管理的,还是会产生不可管理的子集。

输入格式

输入的第一行包含两个空格隔开的整数 $m$ 和 $n$($1 \le m \le 150$,$1 \le n \le 400$,$m \le n$)。

接下来的 $m$ 行通过一个 $m \times n$ 的矩阵描述网络拓扑。这些行中的每一行都包含 $n$ 个空格隔开的整数,每个整数为 0 或 1。在输入的第 $1 + i$ 行(对于 $1 \le i \le m$)中的第 $j$ 个数(对于 $1 \le j \le n$)如果为 1,则表示终端 $i$ 可以连接到服务器 $j$;如果为 0,则表示不能连接。

输出格式

如果给定的网络拓扑是完全可管理的,你只需要在输出的第一行打印 1

否则,你应该在输出的第一行打印 0,并在第二行以 $m$ 个空格隔开的整数形式打印一个不可管理的服务器子集(表示服务器编号,顺序任意)。如果存在多个不可管理的子集,你可以打印其中任意一个。

样例

输入样例 1

3 6
1 1 1 1 0 0
0 1 1 1 1 0
0 0 1 1 1 1

输出样例 1

1

输入样例 2

3 6
1 1 1 1 0 0
0 1 1 1 0 0
0 0 1 1 1 1

输出样例 2

0
1 5 6

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.