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

建议使用的浏览器:

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

6094:Rikka with K-Match

题目描述
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:

Yuta has a graph $G$ with $n$ nodes $(i,j)(1 \leq i \leq n,1 \leq j \leq m)$. There is an edge between $(a,b)$ and $(c,d)$ if and only if $|a-c|+|b-d|=1$. Each edge has its weight.

Now Yuta wants to calculate the minimum weight $K$-matching of $G$.

It is too difficult for Rikka. Can you help her?  

An edge set $S$ is a match of $G=\langle V,E \rangle$ if and only if each nodes in $V$ connects to at most one edge in $S$. A match $S$ is a $K$-match if and only if $|S|=K$. The weight of a match $S$ is the sum of the weights of the edges in $S$. And finally, the minimum weight $K$-matching of $G$ is defined as the $K$-match of $G$ with the minimum weight.
输入解释
The first line contains a number $t(1 \leq t \leq 1000)$, the number of the testcases. And there are no more than $3$ testcases with $n > 100$.

For each testcase, the first line contains three numbers $n,m,K(1 \leq n \leq 4 \times 10^4,1 \leq m \leq 4),1 \leq K \leq \lfloor \frac{nm}{2} \rfloor$.

Then $n-1$ lines follow, each line contains $m$ numbers $A_{i,j}(1 \leq A_{i,j}
\leq 10^9)$ -- the weight of the edge between $(i,j)$ and $(i+1,j)$.

If $m>1$, then $n$ lines follow, each line contains $m-1$ numbers $B_{i,j}(1 \leq B_{i,j} \leq 10^9)$ -- the weight of the edge between $(i,j)$ and $(i,j+1)$.
输出解释
For each testcase, print a single line with a single number -- the answer.

It is guaranteed that there exists at least one $K$-match.
输入样例
3
3 3 1
3 4 5
8 9 10
1 2
6 7
11 12
3 3 2
3 4 5
8 9 10
1 2
6 7
11 12
3 3 3
3 4 5
8 9 10
1 2
6 7
11 12
输出样例
1
5
12
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6094

最后修改于 2020-10-25T23:28:19+00:00 由爬虫自动更新

共提交 0

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