FOJ 1467 Pick Up Points

Problem 1467 Pick Up Points

Accept: 163    Submit: 583
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

 

Recently loy are very interested in playing a funny game. There is a board of n*m grid. Each grid has one point or not. If two adjacency grids both have one point, someone can pick them up, and then these two grids have no point. The two grids are adjacency only if the Manhattan distence between them is exactly 1.

The purpose of the game is to gain as many points as possible.

Input

The first line is an interger T, means the number of test cases. Each test case begins with two interger n,m (1 <= n,m <= 100), means the size of the board is n*m. Next n line, each line has m intergers which is 1 or 0, means the grid has one point or not.

Output

Output the maximum point loy can get.

Sample Input

2
3 4
0 1 0 1
0 1 1 0
1 1 1 1
2 2
1 0
0 1

Sample Output

6
0

Source

LOY

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值