-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path6_subtask1.cpp
61 lines (58 loc) · 1.1 KB
/
6_subtask1.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
58
59
60
61
#include <bits/stdc++.h>
#define endl '\n'
#define eat cin
#define moo cout
#define int long long
using namespace std;
int N, M, dp[300][300], ele[300];
string S[50000];
int32_t main(){
eat.tie(0) -> sync_with_stdio(0);
eat >> N >> M;
for(int i = 0; i < N; i++){
eat >> S[i];
}
for(int i = 0; i < N; i++){
dp[i][i] = 1;
}
int ans = 1;
for(int i = 0; i < N; i++){
fill(ele, ele+M, 0);
for(int j = i; j < N; j++){
bool ok = 0;
for(int k = 0; k < M; k++){
char x = S[j][k];
if(x == '1'){
if(ele[k] == 1) ok = 1;
ele[k] = 1;
}
}
if(!ok) continue;
if(j != i && !dp[i][j-1]) continue;
dp[i][j] = 1;
ans = max(ans, j-i+1);
}
fill(ele, ele+M, 0);
for(int j = i; j >= 0; j--){
bool ok = 0;
for(int k = 0; k < M; k++){
char x = S[j][k];
if(x == '1'){
if(ele[k] == 1) ok = 1;
ele[k] = 1;
}
}
if(!ok) continue;
if(j != i && !dp[j+1][i]) continue;
dp[j][i] = 1;
ans = max(ans, i-j+1);
}
}
/*for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
moo << dp[i][j] << ' ';
}
moo << endl;
}*/
moo << ans << endl;
}