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

建议使用的浏览器:

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

2483:Counting square

题目描述
There is a matrix of size R rows by C columns. Each element in the matrix is either “0” or “1”. A square is called magic square if it meets the following three conditions.
(1)  The elements on the four borders are all “1”.
(2)  Inside the square (excluding the elements on the borders), the number of “1”s and the number of “0”s are different at most by 1.
(3)  The size of the square is at least 2 by 2.
Now given the matrix, please tell me how many magic square are there in the matrix.
输入解释
The input begins with a line containing an integer T, the number of test cases.
Each case begins with two integers R, C(1<=R,C<=300), representing the size of the matrix. Then R lines follow. Each contains C integers, either 0 or 1. The integers are separated by a single space.
输出解释
For each case, output the number of magic square in a single line.
输入样例
3
4 4
1 1 1 1
1 0 1 1
1 1 0 1
1 1 1 1
5 5
1 0 1 1 1
1 0 1 0 1
1 1 0 1 1
1 0 0 1 1
1 1 1 1 1
2 2
1 1
1 1
输出样例
3
2
1
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-2483

最后修改于 2020-10-25T22:53:53+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/2000MS(Java/Others) 32768/32768K(Java/Others)