-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path836 Largest Submatrix.cpp
57 lines (57 loc) · 1.41 KB
/
836 Largest Submatrix.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//============================================================================
// Name : Riham.cpp
// Author : Remo
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define Set(v,d) memset(v, d, sizeof(v))
#define oo 1000000007 //infinity
/** ---------------------------Declarations--------------------------- **/
int N, T, m;
string s;
/** ----------------------------Functions----------------------------- **/
/**********************************************************************************/
int main() {
// freopen("In.txt", "r", stdin);
// freopen("Out.txt", "w", stdout);
scanf("%d\n", &T);
while(T--){
vector<string>arr;
int Max = -oo, cnt = 0;
cin>>s;
arr.push_back(s);
N = m = s.size();
while(--m){
cin>>s;
arr.push_back(s);
}
bool exit = 1;
for(int i=0; i<N; i++)
for(int j=0; j<N; j++)
for(int k=i; k<N; k++)
for(int q=j; q<N; q++){
for(int a=i; a<=k; a++){
for(int b=j; b<=q; b++){
if(arr[a][b] == '0'){
exit = 0;
cnt = 0;
break;
}
cnt++;
}
if(!exit){
exit = 1;
break;
}
}
Max = max(Max, cnt);
cnt = 0;
}
printf("%d\n", Max);
if(T)puts("");
}
return 0;
}