A11150 | Roads in the Kingdom
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In the Kingdom K., there are $n$ towns numbered with integers from $1$ to $n$ . The towns are connected by $n$ bi-directional roads numbered with integers from $1$ to $n$ . The $i$ -th road connects the towns $u_{i}$ and $v_{i}$ and its length is $l_{i}$ . There is no more than one road between two towns. Also, there are no roads that connect the towns with itself.
Let's call the inconvenience of the roads the maximum of the shortest distances between all pairs of towns.
Because of lack of money, it was decided to close down one of the roads so that after its removal it is still possible to reach any town from any other. You have to find the minimum possible inconvenience of the roads after closing down one of the roads.
Let's call the inconvenience of the roads the maximum of the shortest distances between all pairs of towns.
Because of lack of money, it was decided to close down one of the roads so that after its removal it is still possible to reach any town from any other. You have to find the minimum possible inconvenience of the roads after closing down one of the roads.
输入格式
The first line contains the integer $n$ ( $3<=n<=2·10^{5}$ ) — the number of towns and roads.
The next $n$ lines contain the roads description. The $i$ -th from these lines contains three integers $u_{i}$ , $v_{i}$ , $l_{i}$ ( $1<=u_{i},v_{i}<=n$ , $1<=l_{i}<=10^{9}$ ) — the numbers of towns connected by the $i$ -th road and the length of the $i$ -th road. No road connects a town to itself, no two roads connect the same towns.
It's guaranteed that it's always possible to close down one of the roads so that all the towns are still reachable from each other.
The next $n$ lines contain the roads description. The $i$ -th from these lines contains three integers $u_{i}$ , $v_{i}$ , $l_{i}$ ( $1<=u_{i},v_{i}<=n$ , $1<=l_{i}<=10^{9}$ ) — the numbers of towns connected by the $i$ -th road and the length of the $i$ -th road. No road connects a town to itself, no two roads connect the same towns.
It's guaranteed that it's always possible to close down one of the roads so that all the towns are still reachable from each other.
输出格式
Print a single integer — the minimum possible inconvenience of the roads after the refusal from one of the roads.
输入输出样例
输入 #1
3 1 2 4 2 3 5 1 3 1
输出 #1
5
输入 #2
5 2 3 7 3 1 9 4 1 8 3 5 4 4 5 5
输出 #2
18
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted