A9161 | Ciel and Flipboard
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 . 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.
It's known that $n$ is an odd number, so let's introduce . 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.
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.


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted