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

建议使用的浏览器:

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

6875:Yajilin

题目描述
You are given a $n\times n$ rectangular grid of squares. You want to color some cells to black, such that

- Black cells do not touch each other orthogonally(they do not share a side).
- We can draw a single continuous non-intersecting loop that passes through each cell that is not black. The loop must "enter" each cell from the centre of one of its four sides and "exit" from a different side; all turns are 90 degrees.

The following is an example.



In this problem, the weight of cells $(i,j) (1\leq i,j \leq n)$ is $w_{i,j}$. You want to color some cells black, and maximize the sum of weights of these cells.
输入解释
The first line contains an integer $T(1\leq T\leq 30)$- the number of test cases.

For each test case, the first line contains an integer $n(2\leq n\leq 10)$ , each of the following $n$ lines contains $n$ integers $w_{i,j} (0\leq w_{i,j}\leq 10^6)$. The $j$-th number in the $i$-th line indicates the weight of cells in the $i$-th row and the $j$-th column.
输出解释
For each test case, output a number - the answer.
输入样例
2
3
9 8 7
8 8 2
10 4 7
4
7 5 2 4
3 3 5 4
2 2 7 1
8 9 6 8
输出样例
10
28
来自杭电HDUOJ的附加信息
Recommend IceyWang

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

源链接: HDU-6875

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

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 262144/262144K(Java/Others)