编程介的小学生 2019-03-10 14:29 采纳率: 20.5%
浏览 209

棋盘图案的二进制的一个编码的问题的求解过程,运用 C语言编程的具体做法

Problem Description
A chessboard is a NxN binary matrix with rows and columns numbered from 1 to N. Each position of the matrix is black (1) if the sum of the row number and the column number is even; otherwise it is white (0). The following pictures show how a chessboard looks like for N=1, 2 and 3.

Given a NxN binary matrix, find the size of the largest chessboard completely located inside the matrix, as well as the number of chessboards having the largest size (these chessboards may overlap).

Input
The first line of input contains an integer number T, representing the number of test cases to follow. Each test case contains on the first line an integer number N (1<=N<=2000), representing the number of rows and columns of the given matrix. The next N lines describe the matrix: each line contains N characters, which may be either ‘1’ (denoting a black square) or ‘0’ (denoting a white square); at the end of each line there will be a new line character. The matrix will contain at least one ‘1’ character.

Output
For each of the T test cases, in the order given in the input, print one line containing the number of rows and colums of the largest chessboard, followed by a blank and then the number of chessboards having the largest size.

Sample Input
1
5
00101
11010
00101
01010
11101

Sample Output
3 3

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘