7597: Yajilin

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

You are given a n×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)(1i,jn) is wi,j . You want to color some cells black, and maximize the sum of weights of these cells.

输入格式

The first line contains an integer T(1T30) - the number of test cases.

For each test case, the first line contains an integer n(2n10) , each of the following n lines contains n integers wi,j(0wi,j106) . 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