#P2735. Reliable Nets
Reliable Nets
描述
你负责设计校园网络连接各个建筑,并关注其可靠性和成本。因此,你决定在网络中引入冗余,同时保持成本最低。具体来说,你要构建一张最便宜的网络,使得任意一条链路断开后,所有建筑仍可互通。我们称之为最小可靠网。
输入
有多组测试。每组测试第一行包含两个整数 $n$(≤15)和 $m$(≤20),分别表示建筑数量(编号1到$n$)和潜在连线路数。若 $n=m=0$ 则结束输入。接下来 $m$ 行,每行格式为:
b1 b2 c
表示连接建筑 $b_1$ 和 $b_2$ 的成本为 $c$。所有连接双向。
输出
对每个测试,如果存在最小可靠网,输出:
The minimal cost for test case p is c.
其中 $p$ 为测试编号(从1开始),$c$ 为网络总成本。若无可靠网可能,则输出:
There is no reliable net possible for test case p.
输入数据 1
4 5
1 2 1
1 3 2
2 4 2
3 4 1
2 3 1
2 1
1 2 5
0 0
输出数据 1
The minimal cost for test case 1 is 6.
There is no reliable net possible for test case 2.
来源
East Central North America 2005