Codeforces Round 190 (Div. 1)
D
Ciel and Flipboard
Codeforces
2900
原题
← CE →
翻译中…

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 image. 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.

翻译中…

Input

翻译中…

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

翻译中…

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

翻译中…

Note

翻译中…

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.

翻译中…

image

翻译中…

样例

Input #1
3
-1 -1 1
-1 1 -1
1 -1 -1
Output #1
9
InputCopy OutputCopy
Input #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
Output #2
18
InputCopy OutputCopy
题目信息
题号
321D
时间限制
4 s
内存限制
256 MB
标签
动态规划
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。