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

建议使用的浏览器:

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

6958:KD-Graph

题目描述
Let’s call a weighted connected undirected graph of $n$ vertices and m edges KD-Graph, if the
following conditions fulfill:

* $n$ vertices are strictly divided into $K$ groups, each group contains at least one vertice

* if vertices $p$ and $q$ ( $p$ ≠ $q$ ) are in the same group, there must be at least one path between $p$ and $q$ meet the max value in this path is less than or equal to $D$.

* if vertices $p$ and $q$ ( $p$ ≠ $q$ ) are in different groups, there can’t be any path between $p$ and $q$ meet the max value in this path is less than or equal to $D$.

You are given a weighted connected undirected graph $G$ of $n$ vertices and $m$ edges and an integer $K$.

Your task is find the minimum non-negative $D$ which can make there is a way to divide the $n$ vertices into $K$ groups makes $G$ satisfy the definition of KD-Graph.Or $-1$ if there is no such $D$ exist.
输入解释
The first line contains an integer $T$ (1≤ $T$ ≤5) representing the number of test cases.
For each test case , there are three integers $n,m,k(2≤n≤100000,1≤m≤500000,1≤k≤n)$ in the first line.
Each of the next $m$ lines contains three integers $u, v$ and $c$ $(1≤v,u≤n,v≠u,1≤c≤10^9)$ meaning that there is an edge between vertices $u$ and $v$ with weight $c$.
输出解释
For each test case print a single integer in a new line.
输入样例
2
3 2 2
1 2 3
2 3 5
3 2 2
1 2 3
2 3 3
输出样例
3
-1

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

源链接: HDU-6958

最后修改于 2021-10-23T19:10:49+00:00 由爬虫自动更新

共提交 0

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