当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3493:Chessboard Puzzle

题目描述

Farmer John has invented a game, Chessboard Puzzle, which perplexes lots of puzzle fanatics. The game is quite simple. Given a chessboard in such a way that every grid is presented by a specified integer, you are obliged to color every grid in white or black. For each pair of grids subjected to following restraints:

  1. they are neighbor, in detail, sharing common edge;
  2. they are colored differently.

add the product of the two specified integers to the score. And your goal is to maximum the total score. Could you write a program to tell John the maximum score?

输入解释

The input describes one puzzle which begins with two integer n, m(1 ≤ n, m ≤16). Then n lines follow. Each contains m integers. The j-th number on i-th row corresponds to the grid(i,j). The absolute value of each number is less than 1000.

输出解释

Print the maximum score in a line.  

输入样例
5 5
-136 -712 -286 -622 564 
6 -899 623 -152 -519 
904 982 593 799 93 
-815 122 -307 572 -359 
921 757 -888 351 935
输出样例
5852863

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3493

最后修改于 2020-10-29T07:02:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 131072