CF835F.Roads in the Kingdom
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
在王国 K. 中,共有 n 座城镇,编号为 1 到 n。这些城镇由 n 条双向道路连接,道路编号为 1 到 n。第 i 条道路连接城镇 ui 和 vi,其长度为 li。任意两座城镇之间至多只有一条道路,且不存在连接某座城镇与其自身的道路。
我们定义道路系统的“不便度”为所有城镇对之间的最短距离的最大值。
由于资金短缺,决定关闭其中一条道路,使得关闭后任意两座城镇之间仍可互相到达(即图保持连通)。你需要求出:在满足上述条件的前提下,关闭某一条道路后所能达到的最小可能的不便度。
输入格式
The first line contains the integer n (3 ≤ n ≤ 2·105) — 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 ≤ 109) — 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.
第一行包含一个整数 n(3≤n≤2⋅105)—— 城镇与道路的总数。
接下来的 n 行描述了这些道路。其中第 i 行包含三个整数 ui、vi、li(1≤ui,vi≤n,1≤li≤109)—— 分别表示第 i 条道路所连接的两个城镇的编号以及该道路的长度。不存在连接某城镇到其自身的道路,也不存在两条道路连接完全相同的两个城镇。
保证总可以关闭其中一条道路,使得所有城镇之间仍然相互可达。
输出格式
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
输入解题思路,AI测评打分。不知道怎么写?