303573: CF690C2. Brain Network (medium)
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Brain Network (medium)
题意翻译
给出一个 $n$ 个点 $m$ 条边的有效的神经网络,定义: - 大脑的之间的距离:即大脑之间的最短距离; - 神经网络的权值:该图中大脑之间的距离的最大值。 请求出给出的神经网络的权值。 其中有效神经网络的定义: - 任意两个大脑都是连通的; - 删去任意一条边都会使得上述条件不成立。 ### 输入格式 第一行两个整数 $n,m$,分别表示点的个数和边的个数。 接下来 $m$ 行,每行两个整数 $u,v$,表示 $u,v$ 之间有一条无向边。 ### 输出格式 一行一个整数,表示该图的权值。 **说明与提示** $1 \le n,m \le 10^5$。 感谢 @[_Wolverine](https://www.luogu.com.cn/user/120362) 提供的翻译题目描述
Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of $ n $ brains and $ m $ brain connectors joining some pairs of brains together. It was observed that the intellectual abilities of a zombie depend mainly on the topology of its nervous system. More precisely, we define the distance between two brains $ u $ and $ v $ ( $ 1<=u,v<=n $ ) as the minimum number of brain connectors used when transmitting a thought between these two brains. The brain latency of a zombie is defined to be the maximum distance between any two of its brains. Researchers conjecture that the brain latency is the crucial parameter which determines how smart a given zombie is. Help them test this conjecture by writing a program to compute brain latencies of nervous systems. In this problem you may assume that any nervous system given in the input is valid, i.e., it satisfies conditions (1) and (2) from the easy version.输入输出格式
输入格式
The first line of the input contains two space-separated integers $ n $ and $ m $ ( $ 1<=n,m<=100000 $ ) denoting the number of brains (which are conveniently numbered from $ 1 $ to $ n $ ) and the number of brain connectors in the nervous system, respectively. In the next $ m $ lines, descriptions of brain connectors follow. Every connector is given as a pair of brains $ a b $ it connects ( $ 1<=a,b<=n $ and $ a≠b $ ).
输出格式
Print one number – the brain latency.
输入输出样例
输入样例 #1
4 3
1 2
1 3
1 4
输出样例 #1
2
输入样例 #2
5 4
1 2
2 3
3 4
3 5
输出样例 #2
3