You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
/*
测试用例I
5 6
1 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
0 1 0 0 0 1
1 0 1 0 0 0
答案
4
测试用例II
5 6
1 0 1 0 0 0
0 1 0 1 1 0
1 0 0 0 1 0
0 1 0 0 0 1
1 0 1 0 0 0
答案
3
*/
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 110;
int a[N][N];
int res;
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[i][j];
// 1e8 =100000000
// 1500000000
for (int i = 1; i <= n; i++) // 1000
for (int j = 1; j <= m; j++) { // 1000
for (int k = 0;; k++) { // 1000 *SQRT(2)=1500
if (i + k > n || j + k > m) break; //越界
if (a[i + k][j + k] == 0) break;
//从[i,j]出发边长长度为k+1的矩形内部数字为1的有多少个
res = max(res, k + 1);
}
}
cout << res << endl;
return 0;
}