# Game SAP

Problem Description
onmylove has invented a game on n × m grids. There is one positive integer on each grid. Now you can take the numbers from the grids to make your final score as high as possible. The way to get score is like
the following:
● At the beginning, the score is 0;
● If you take a number which equals to x, the score increase x;
● If there appears two neighboring empty grids after you taken the number, then the score should be decreased by 2(x&y). Here x and y are the values used to existed on these two grids. Please pay attention that "neighboring grids" means there exits and only exits one common border between these two grids.

Since onmylove thinks this problem is too easy, he adds one more rule:
● Before you start the game, you are given some positions and the numbers on these positions must be taken away.
Can you help onmylove to calculate: what's the highest score onmylove can get in the game?

Input
Multiple input cases. For each case, there are three integers n, m, k in a line.
n and m describing the size of the grids is n ×m. k means there are k positions of which you must take their numbers. Then following n lines, each contains m numbers, representing the numbers on the n×m grids.Then k lines follow. Each line contains two integers, representing the row and column of one position
and you must take the number on this position. Also, the rows and columns are counted start from 1.
Limits: 1 ≤ n, m ≤ 50, 0 ≤ k ≤ n × m, the integer in every gird is not more than 1000.

Output
For each test case, output the highest score on one line.

Sample Input
2 2 1 2 2 2 2 1 1 2 2 1 2 7 4 1 1 1

Sample Output
4 9

• 写回答

#### 1条回答默认 最新

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

#### 悬赏问题

• ¥15 请教某软件缓存Ts文件破解合并mp4的方法
• ¥15 求小游戏炸弹人中关于敌人的C＋＋代码
• ¥15 拿到这个服务器最高权限有偿
• ¥50 来个抓app跳转支付宝转链接的
• ¥15 remotes安装提示没有description文件
• ¥15 AttributeError: 'NoneType' object has no attribute 'drop_duplicates'报错
• ¥15 以下代码，运行结果报错