Problem I. KD-Graph
时间限制 1500 ms
内存限制 64 MB
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.
输入数据
输出数据
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
样例输出
$ Mathjax font initiator $