A10566 | Brain Network (medium)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted