#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#pragma GCC ("O3")
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 && I * J >= ans; 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;
}
Compilation message
bomb.cpp:5:0: warning: ignoring #pragma GCC [-Wunknown-pragmas]
#pragma GCC ("O3")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
632 KB |
Output is correct |
3 |
Correct |
27 ms |
26872 KB |
Output is correct |
4 |
Correct |
34 ms |
26872 KB |
Output is correct |
5 |
Correct |
35 ms |
376 KB |
Output is correct |
6 |
Correct |
7 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 |
632 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
2 ms |
504 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 |
1400 KB |
Output is correct |
20 |
Correct |
6 ms |
1400 KB |
Output is correct |
21 |
Correct |
5 ms |
888 KB |
Output is correct |
22 |
Correct |
6 ms |
1252 KB |
Output is correct |
23 |
Correct |
8 ms |
1528 KB |
Output is correct |
24 |
Incorrect |
3 ms |
1272 KB |
Output isn't correct |
25 |
Incorrect |
8 ms |
1528 KB |
Output isn't correct |
26 |
Correct |
9 ms |
1528 KB |
Output is correct |
27 |
Correct |
137 ms |
4148 KB |
Output is correct |
28 |
Correct |
215 ms |
4316 KB |
Output is correct |
29 |
Incorrect |
226 ms |
5496 KB |
Output isn't correct |
30 |
Incorrect |
405 ms |
6392 KB |
Output isn't correct |
31 |
Incorrect |
327 ms |
4984 KB |
Output isn't correct |
32 |
Incorrect |
301 ms |
6008 KB |
Output isn't correct |
33 |
Correct |
509 ms |
6776 KB |
Output is correct |
34 |
Correct |
106 ms |
4728 KB |
Output is correct |
35 |
Correct |
453 ms |
6736 KB |
Output is correct |
36 |
Correct |
615 ms |
6776 KB |
Output is correct |
37 |
Correct |
2 ms |
504 KB |
Output is correct |
38 |
Execution timed out |
1077 ms |
57696 KB |
Time limit exceeded |
39 |
Correct |
2 ms |
504 KB |
Output is correct |
40 |
Execution timed out |
1078 ms |
15608 KB |
Time limit exceeded |
41 |
Correct |
2 ms |
504 KB |
Output is correct |
42 |
Correct |
8 ms |
1528 KB |
Output is correct |
43 |
Execution timed out |
1076 ms |
57640 KB |
Time limit exceeded |
44 |
Incorrect |
387 ms |
6904 KB |
Output isn't correct |
45 |
Execution timed out |
1077 ms |
57592 KB |
Time limit exceeded |
46 |
Execution timed out |
1080 ms |
57592 KB |
Time limit exceeded |
47 |
Execution timed out |
1075 ms |
57592 KB |
Time limit exceeded |
48 |
Execution timed out |
1078 ms |
57528 KB |
Time limit exceeded |
49 |
Execution timed out |
1085 ms |
57720 KB |
Time limit exceeded |
50 |
Execution timed out |
1068 ms |
57708 KB |
Time limit exceeded |
51 |
Execution timed out |
1090 ms |
57592 KB |
Time limit exceeded |
52 |
Execution timed out |
1089 ms |
57592 KB |
Time limit exceeded |
53 |
Execution timed out |
1089 ms |
57592 KB |
Time limit exceeded |
54 |
Execution timed out |
1085 ms |
57580 KB |
Time limit exceeded |
55 |
Execution timed out |
1099 ms |
57544 KB |
Time limit exceeded |
56 |
Execution timed out |
1069 ms |
57720 KB |
Time limit exceeded |
57 |
Execution timed out |
1099 ms |
57592 KB |
Time limit exceeded |
58 |
Execution timed out |
1092 ms |
57592 KB |
Time limit exceeded |
59 |
Execution timed out |
1083 ms |
57664 KB |
Time limit exceeded |
60 |
Execution timed out |
1076 ms |
57592 KB |
Time limit exceeded |
61 |
Execution timed out |
1070 ms |
57520 KB |
Time limit exceeded |
62 |
Execution timed out |
1081 ms |
57588 KB |
Time limit exceeded |
63 |
Execution timed out |
1078 ms |
57620 KB |
Time limit exceeded |
64 |
Execution timed out |
1060 ms |
57564 KB |
Time limit exceeded |
65 |
Execution timed out |
1080 ms |
57584 KB |
Time limit exceeded |
66 |
Execution timed out |
1063 ms |
57624 KB |
Time limit exceeded |
67 |
Execution timed out |
1059 ms |
57592 KB |
Time limit exceeded |
68 |
Execution timed out |
1076 ms |
57584 KB |
Time limit exceeded |
69 |
Execution timed out |
1079 ms |
57636 KB |
Time limit exceeded |
70 |
Execution timed out |
1067 ms |
46124 KB |
Time limit exceeded |
71 |
Execution timed out |
1077 ms |
57592 KB |
Time limit exceeded |
72 |
Execution timed out |
1062 ms |
57592 KB |
Time limit exceeded |
73 |
Execution timed out |
1080 ms |
57552 KB |
Time limit exceeded |
74 |
Execution timed out |
1074 ms |
57592 KB |
Time limit exceeded |
75 |
Execution timed out |
1081 ms |
57592 KB |
Time limit exceeded |
76 |
Execution timed out |
1078 ms |
57564 KB |
Time limit exceeded |
77 |
Execution timed out |
1054 ms |
57664 KB |
Time limit exceeded |
78 |
Execution timed out |
1093 ms |
57592 KB |
Time limit exceeded |
79 |
Execution timed out |
1070 ms |
57516 KB |
Time limit exceeded |
80 |
Execution timed out |
1086 ms |
57592 KB |
Time limit exceeded |
81 |
Execution timed out |
1087 ms |
57720 KB |
Time limit exceeded |
82 |
Execution timed out |
1084 ms |
57604 KB |
Time limit exceeded |
83 |
Execution timed out |
1065 ms |
57592 KB |
Time limit exceeded |
84 |
Execution timed out |
1089 ms |
57592 KB |
Time limit exceeded |
85 |
Execution timed out |
1081 ms |
57592 KB |
Time limit exceeded |
86 |
Execution timed out |
1062 ms |
57620 KB |
Time limit exceeded |
87 |
Execution timed out |
1062 ms |
57556 KB |
Time limit exceeded |
88 |
Execution timed out |
1080 ms |
57600 KB |
Time limit exceeded |
89 |
Execution timed out |
1084 ms |
57592 KB |
Time limit exceeded |
90 |
Execution timed out |
1085 ms |
46072 KB |
Time limit exceeded |
91 |
Execution timed out |
1086 ms |
57596 KB |
Time limit exceeded |
92 |
Execution timed out |
1076 ms |
57592 KB |
Time limit exceeded |
93 |
Execution timed out |
1070 ms |
57608 KB |
Time limit exceeded |
94 |
Execution timed out |
1080 ms |
57752 KB |
Time limit exceeded |
95 |
Execution timed out |
1079 ms |
57592 KB |
Time limit exceeded |
96 |
Execution timed out |
1069 ms |
57564 KB |
Time limit exceeded |
97 |
Execution timed out |
1039 ms |
57564 KB |
Time limit exceeded |
98 |
Execution timed out |
1084 ms |
57616 KB |
Time limit exceeded |
99 |
Execution timed out |
1073 ms |
57620 KB |
Time limit exceeded |
100 |
Execution timed out |
1047 ms |
57548 KB |
Time limit exceeded |