编程介的小学生 2017-11-04 03:26 采纳率: 20.5%
浏览 746
已采纳

One to Four

Problem Description
Given one n * m matrix consist of only positive numbers, It is guaranteed that the product of n and m is a multiple of 4, therefore, we can divide it into four identical parts(that is, every part is a 4-connected subset and we can obtain each part from each other by rotation and translation, every element must be included in exactly one part).

(Grids that from the same part are labeled by the same colour, all four partitions above are valid.)
Note that the partition below is NOT valid because we can only use translation and rotation, no symmetrical reverse:

Once we choose a partition, we can choose some translation and rotation to make these four parts coincide, finally we add up every four values lying on the same grid and choose the minimum sum as the score of the partition and transformation.
Now you're given the matrix, your task is to choose a proper partition and transformation to get the maximum score.

Input
There are several testcases, please process till EOF.
In each test case, first line contains two integers n and m. Following n lines each contains m integers Aij, describing the matrix.
1 ≤ n,m ≤ 30,1 ≤ Aij ≤ 10000.

Output
For each testcase output one line contains one integer: the maximum score you can get.

Sample Input
2 4
1 1 1 1
2 2 2 2
4 4
1 1 1 3
2 1 3 3
2 2 4 3
2 4 4 4

Sample Output
6
10

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-29 15:46
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题