测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A9161. Ciel and Flipboard

编程题 普及/提高-

题目描述

Fox Ciel has a board with $n$ rows and $n$ columns, there is one integer in each cell.

It's known that $n$ is an odd number, so let's introduce ![](/uploads/acgo/image/164eecc54116df56_9e727f65e4b3.jpeg). Fox Ciel can do the following operation many times: she choose a sub-board with size $x$ rows and $x$ columns, then all numbers in it will be multiplied by -1.

Return the maximal sum of numbers in the board that she can get by these operations.

输入格式

The first line contains an integer $n$ , ( $1<=n<=33$ , and $n$ is an odd integer) — the size of the board.

Each of the next $n$ lines contains $n$ integers — the numbers in the board. Each number doesn't exceed $1000$ by its absolute value.

输出格式

Output a single integer: the maximal sum of numbers in the board that can be accomplished.

输入输出样例

输入 #1
3
-1 -1 1
-1 1 -1
1 -1 -1
输出 #1
9
输入 #2
5
-2 0 0 0 -2
0 -2 0 -2 0
0 0 -2 0 0
0 -2 0 -2 0
-2 0 0 0 -2
输出 #2
18

说明/提示

In the first test, we can apply this operation twice: first on the top left $2×2$ sub-board, then on the bottom right $2×2$ sub-board. Then all numbers will become positive.

![](/uploads/acgo/image/bcb9711045c4300f_69470bf37e23.jpeg)
上一题 去做题 下一题