#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;
const int N = 2600;
int n, m;
char ch[N][N];
int A[N][N], B[N][N];
int main()
{
ios::sync_with_stdio(false);
cin>>n>>m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin>>ch[i][j];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
A[i][j] = A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1] + ch[i][j] - '0';
int J = m;
int ans = 0;
for (int I = 1; I <= n && J; I++){
while (J){
bool ok = 1;
for (int i = 0; i <= n; i++)
for (int j = 0; j <= m; j++)
B[i][j] = 0;
for (int i = 0; i + I <= n; i++)
for (int j = 0; j + J <= m; j++){
int x = A[i + I][j + J] - A[i + I][j] - A[i][j + J] + A[i][j];
if (x == I * J){
B[i + I + 1][j + J + 1]++;
B[i + 1][j + J + 1]--;
B[i + I + 1][j + 1]--;
B[i + 1][j + 1]++;
}
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
B[i][j] += B[i - 1][j] + B[i][j - 1] - B[i - 1][j - 1];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (ch[i][j] == '1' && B[i][j] == 0)
ok = 0;
if (ok)
break;
J--;
}
ans = max (ans, I * J);
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
30 ms |
26744 KB |
Output is correct |
4 |
Correct |
33 ms |
26744 KB |
Output is correct |
5 |
Correct |
35 ms |
376 KB |
Output is correct |
6 |
Correct |
8 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
632 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Correct |
2 ms |
632 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
552 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
2 ms |
636 KB |
Output is correct |
17 |
Correct |
4 ms |
1144 KB |
Output is correct |
18 |
Correct |
4 ms |
1144 KB |
Output is correct |
19 |
Correct |
6 ms |
1528 KB |
Output is correct |
20 |
Correct |
7 ms |
1400 KB |
Output is correct |
21 |
Correct |
16 ms |
1016 KB |
Output is correct |
22 |
Correct |
6 ms |
1252 KB |
Output is correct |
23 |
Correct |
9 ms |
1528 KB |
Output is correct |
24 |
Correct |
5 ms |
1272 KB |
Output is correct |
25 |
Correct |
10 ms |
1528 KB |
Output is correct |
26 |
Correct |
9 ms |
1528 KB |
Output is correct |
27 |
Correct |
136 ms |
4188 KB |
Output is correct |
28 |
Correct |
210 ms |
4216 KB |
Output is correct |
29 |
Correct |
299 ms |
5536 KB |
Output is correct |
30 |
Correct |
528 ms |
6392 KB |
Output is correct |
31 |
Correct |
402 ms |
5096 KB |
Output is correct |
32 |
Correct |
412 ms |
5880 KB |
Output is correct |
33 |
Correct |
627 ms |
6648 KB |
Output is correct |
34 |
Correct |
107 ms |
4728 KB |
Output is correct |
35 |
Correct |
481 ms |
6648 KB |
Output is correct |
36 |
Correct |
605 ms |
6776 KB |
Output is correct |
37 |
Correct |
2 ms |
504 KB |
Output is correct |
38 |
Execution timed out |
1070 ms |
63576 KB |
Time limit exceeded |
39 |
Correct |
2 ms |
632 KB |
Output is correct |
40 |
Execution timed out |
1085 ms |
15608 KB |
Time limit exceeded |
41 |
Correct |
2 ms |
632 KB |
Output is correct |
42 |
Correct |
10 ms |
1528 KB |
Output is correct |
43 |
Execution timed out |
1078 ms |
63608 KB |
Time limit exceeded |
44 |
Correct |
743 ms |
6784 KB |
Output is correct |
45 |
Execution timed out |
1081 ms |
63608 KB |
Time limit exceeded |
46 |
Execution timed out |
1069 ms |
63736 KB |
Time limit exceeded |
47 |
Execution timed out |
1083 ms |
63608 KB |
Time limit exceeded |
48 |
Execution timed out |
1072 ms |
63644 KB |
Time limit exceeded |
49 |
Execution timed out |
1084 ms |
63608 KB |
Time limit exceeded |
50 |
Execution timed out |
1085 ms |
63608 KB |
Time limit exceeded |
51 |
Execution timed out |
1068 ms |
63580 KB |
Time limit exceeded |
52 |
Execution timed out |
1074 ms |
63660 KB |
Time limit exceeded |
53 |
Execution timed out |
1076 ms |
63608 KB |
Time limit exceeded |
54 |
Execution timed out |
1089 ms |
63612 KB |
Time limit exceeded |
55 |
Execution timed out |
1089 ms |
63608 KB |
Time limit exceeded |
56 |
Execution timed out |
1075 ms |
63608 KB |
Time limit exceeded |
57 |
Execution timed out |
1080 ms |
63736 KB |
Time limit exceeded |
58 |
Execution timed out |
1081 ms |
63608 KB |
Time limit exceeded |
59 |
Execution timed out |
1074 ms |
63612 KB |
Time limit exceeded |
60 |
Execution timed out |
1071 ms |
63560 KB |
Time limit exceeded |
61 |
Execution timed out |
1080 ms |
63608 KB |
Time limit exceeded |
62 |
Execution timed out |
1072 ms |
63480 KB |
Time limit exceeded |
63 |
Execution timed out |
1078 ms |
63608 KB |
Time limit exceeded |
64 |
Execution timed out |
1071 ms |
63608 KB |
Time limit exceeded |
65 |
Execution timed out |
1082 ms |
63608 KB |
Time limit exceeded |
66 |
Execution timed out |
1080 ms |
63612 KB |
Time limit exceeded |
67 |
Execution timed out |
1077 ms |
63632 KB |
Time limit exceeded |
68 |
Execution timed out |
1069 ms |
63528 KB |
Time limit exceeded |
69 |
Execution timed out |
1091 ms |
63352 KB |
Time limit exceeded |
70 |
Execution timed out |
1075 ms |
46096 KB |
Time limit exceeded |
71 |
Execution timed out |
1069 ms |
59256 KB |
Time limit exceeded |
72 |
Execution timed out |
1072 ms |
57560 KB |
Time limit exceeded |
73 |
Execution timed out |
1085 ms |
57608 KB |
Time limit exceeded |
74 |
Execution timed out |
1088 ms |
62748 KB |
Time limit exceeded |
75 |
Execution timed out |
1079 ms |
63460 KB |
Time limit exceeded |
76 |
Execution timed out |
1063 ms |
63396 KB |
Time limit exceeded |
77 |
Execution timed out |
1071 ms |
63224 KB |
Time limit exceeded |
78 |
Execution timed out |
1083 ms |
63224 KB |
Time limit exceeded |
79 |
Execution timed out |
1086 ms |
57592 KB |
Time limit exceeded |
80 |
Execution timed out |
1082 ms |
57644 KB |
Time limit exceeded |
81 |
Execution timed out |
1060 ms |
57592 KB |
Time limit exceeded |
82 |
Execution timed out |
1075 ms |
63608 KB |
Time limit exceeded |
83 |
Execution timed out |
1075 ms |
63608 KB |
Time limit exceeded |
84 |
Execution timed out |
1075 ms |
57540 KB |
Time limit exceeded |
85 |
Execution timed out |
1072 ms |
63608 KB |
Time limit exceeded |
86 |
Execution timed out |
1074 ms |
63608 KB |
Time limit exceeded |
87 |
Execution timed out |
1073 ms |
63608 KB |
Time limit exceeded |
88 |
Execution timed out |
1083 ms |
63608 KB |
Time limit exceeded |
89 |
Execution timed out |
1076 ms |
63524 KB |
Time limit exceeded |
90 |
Execution timed out |
1076 ms |
46072 KB |
Time limit exceeded |
91 |
Execution timed out |
1064 ms |
63608 KB |
Time limit exceeded |
92 |
Execution timed out |
1078 ms |
63608 KB |
Time limit exceeded |
93 |
Execution timed out |
1077 ms |
63608 KB |
Time limit exceeded |
94 |
Execution timed out |
1075 ms |
63608 KB |
Time limit exceeded |
95 |
Execution timed out |
1075 ms |
63608 KB |
Time limit exceeded |
96 |
Execution timed out |
1074 ms |
63576 KB |
Time limit exceeded |
97 |
Execution timed out |
1075 ms |
63528 KB |
Time limit exceeded |
98 |
Execution timed out |
1074 ms |
63608 KB |
Time limit exceeded |
99 |
Execution timed out |
1075 ms |
63608 KB |
Time limit exceeded |
100 |
Execution timed out |
1075 ms |
63568 KB |
Time limit exceeded |