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

建议使用的浏览器:

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

5736:Call It What You Want

题目描述
Professor Zhang has heard that the longest path problem cannot be solved in polynomial time for arbitrary graphs unless P = NP. Now, Professor Zhang would like to solve this problem in polynomial time in some graphs.

The longest path problem is the problem of finding a simple path of maximum length in a given graph. A path is called simple if it does not have any repeated vertices. The length of a path is measured by its number of edges on the path.
输入解释
There are multiple test cases. The first line of input contains an integer $T$ (about 350), indicating the number of test cases. For each test case:

The first line contains two integers $n$ and $m$ $(3 \le n \le 10^4, n \le m \le n + 4)$ -- the number of vertices and the number of edges.

Each of the following $m$ lines contains two integers $a_i$ and $b_i$ which denotes an edge between vertices $a_i$ and $b_i$ $(1 \le a_i, b_i \le n, a_i \ne b_i)$.

It is guaranteed that the graph is connected and does not contain multiple edges.
输出解释
For each test case, output an integer denoting the length of the longest path.
输入样例
3
5 5
1 2
2 3
3 4
4 5
5 1
7 7
1 2
2 3
3 4
4 5
5 1
5 6
4 7
7 10
1 2
2 3
3 4
4 5
1 5
2 5
3 5
1 6
5 6
4 7
输出样例
4
6
6
来自杭电HDUOJ的附加信息
Author zimpha
Recommend wange2014

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

源链接: HDU-5736

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

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 65536/65536K(Java/Others)