当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6878:Network Test

题目描述
What connects us all? Well, it must be the Internet nowadays. With access to the Internet, we can play games, watch drama series, chat with friends, shop online, and order takeout conveniently. Who can ever imagine life without the Internet?

A network is composed of hosts and data links. The hosts refer to terminal devices such as personal computers, mobile phones, and servers, as well as other network devices including switches and routers. A data link is a direct connection between two hosts, over which the data packets can be transmitted in either direction. Data links can be implemented in various physical forms; the most common ones are copper cables, optical fibers, and radio waves, to name but a few.

Since it is generally not practical to build data links between every pair of hosts, the data packets may pass through intermediate hosts when the source host and the destination host are not adjacent. There are many possible routes between two hosts, so we need a routing protocol to decide which route to use. The simplest routing protocol is the Spanning Tree Protocol (STP). In STP, only a subset of all data links are enabled such that every two hosts are reachable and there is no cycle in the enabled data links. The set of enabled data links is called a spanning tree, and it is clear that there is a unique path composed of only enabled data links between any two hosts.

The Network Construction Company have just set up a network, and they want to test whether all data links work properly. To do this, they plan to carry out several rounds of testing. In each round of testing, a spanning tree is chosen and the packages are transmitted via only the data links in the spanning tree, so that the connectivity of every enabled data link can be tested. They want to minimize the number of testing rounds conducted, under the premise that every data link in the network is tested in at least one round.
输入解释
The first line of the input consists of only a single integer $T$ $(1 \leq T \leq 50)$, indicating the number of test cases.

Each test case begins with two integers $n, m$ $(2 \leq n \leq 1000, 1 \leq m \leq 2000)$, where $n$ is the number of hosts and $m$ is the number of data links. Then follow $m$ lines, each containing two integers $u, v$ $(1 \leq u, v \leq n, u \neq v)$, denoting a data link between two hosts numbered $u$ and $v$. There may be more than one data link between a pair of hosts. It is guaranteed that every two hosts are reachable via the given data links.

There are no more than 20 test cases with $m > 500$.
输出解释
For each test case, print the minimum number of rounds conducted as an integer in a single line.
输入样例
2
3 3
1 2
2 3
3 1
4 7
1 3
1 2
1 4
3 2
3 4
2 4
4 2
输出样例
2
3
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6878

最后修改于 2020-10-25T23:35:10+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/8000MS(Java/Others) 262144/262144K(Java/Others)