0000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0000001111111111111100000000000000000011111111111111100000000000000000
0000001111111111111100000000000000000011111111111111100000000000000000
0000001111111111111100000000000000000011111111111111100000000000000000
0000001111111111111100000000000000000011111111111111100000000000000000
0000000000000000000000000000000000000011111111111111100000000000000000
0000000000000000000000000000000000000011111111111111100000000000000000
0000000000011111100000000000000000000011111111111111100000000000000000
0000000000011111100000000000000000000011111111111111100000000000000000
0000000000011111100000000000000000000011111111111111100000000000000000
0000000000000000000000000000000000000011111111111111100000000000000000
0000000000000000000000000000000000000011111111111111100000000000000000
0000000000000111111000000000000000000011111111111111100000000000000000
0000000000000100001000000111111000000011111111111111100000000010000000
0000000000000100001000000111111000000000000000000000011000000000000000
0000000000000111111000000111111000000000000000000000011000000000000000
0000000000000000000000000000111111000000000000000000000000000000000000
0000000000000000000000000000111111000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
您将得到一个二维数组,大小为mx n。确保所有字节均为1或0。找到在2d中查看时由1表示的矩形的数量,如上所示。
仅考虑完全填充的矩形进行计数。
矩形必须用0包围,除非它们在边缘上(尽管1的对角线接触矩形是可以的(请参见示例)。
例如,在上面的数组中有5个有效矩形。
您可以使用任何语言。
1
我认为更好的说法是:矩形必须用0或边缘包围
—
Cruncher 2014年
做完了 感谢您用更好的英语措辞。
—
microbian
那
—
Cruncher 2014年
1100\n1100\n0011\n0011
呢
我认为这就是为什么我写“相邻/重叠”的原因。从我的初衷出发,这是2个有效的矩形。但是“周围”条件现在限制了它们。你有更好的方法来解释它
—
microbian
即使在相邻处,对角线是否也意味着相邻也是不明确的。同样模棱两可与否包围手段,围在角落,或只是双方
—
排排坐