题库练习 Corners
← 上一题 下一题 →

A15320 | Corners

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given a matrix consisting of $n$ rows and $m$ columns. Each cell of this matrix contains $0$ or $1$ .

Let's call a square of size $2 \times 2$ without one corner cell an L-shape figure. In one operation you can take one L-shape figure, with at least one cell containing $1$ and replace all numbers in it with zeroes.

Find the maximum number of operations that you can do with the given matrix.

输入格式

The first line contains one integer $t$ ( $1 \leq t \leq 500$ ) — the number of test cases. Then follow the descriptions of each test case.

The first line of each test case contains two integers $n$ and $m$ ( $2 \leq n, m \leq 500$ ) — the size of the matrix.

Each of the following $n$ lines contains a binary string of length $m$ — the description of the matrix.

It is guaranteed that the sum of $n$ and the sum of $m$ over all test cases does not exceed $1000$ .

输出格式

For each test case output the maximum number of operations you can do with the given matrix.

输入输出样例

输入 #1
4
4 3
101
111
011
110
3 4
1110
0111
0111
2 2
00
00
2 2
11
11
输出 #1
8
9
0
2
C++ 编辑器
输入
输出