-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathb.cpp
44 lines (42 loc) · 1.22 KB
/
b.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
#include <bits/stdc++.h>
using namespace std;
int main(){
//freopen("cin", "r", stdin);
int N, M; cin >> N >> M;
string r[N];
int ans = 0;
for(int i = 0; i < N; i++) cin >> r[i];
for(int i = 0; i < N; i++){
for(int j = 0; j < M; j++){
if(r[i][j] == '1'){
continue;
}
for(int k = i; k < N; k++){
for(int l = j; l < M; l++){
if(r[k][l] == '1'){
continue;
}
bool good = true;
for(int x = i; x < k + 1; x++){
for(int y = j; y < l + 1; y++){
if(r[x][y] == '1'){
good = false;
break;
}
}
if(!good){
break;
}
}
if(!good){
break;
}else{
ans = max(ans, 2 * ((k - i + 1) + (l - j + 1)));
}
}
}
}
}
cout << ans << endl;
return 0;
}