#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <vector>
using namespace std;
const int N = 2505;
int dzaxic[N][N];
int ajic[N][N];
int a[N][N];
int n, m;
int M[N];
int main(){
ios_base::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
char c;
cin >> c;
a[i][j] = c - '0';
}
}
int mnw = 1000*1000*1000+5;
int mnh = mnw;
for (int i = 1; i <= n; i++)
{
int now = 0;
for (int j = 1; j <= m; j++){
if (a[i][j]){
now++;
dzaxic[i][j] = now;
}
else{
if(now) mnw = min(mnw, now);
now = 0;
}
}
now = 0;
for (int j = m; j >= 1; j--){
if (a[i][j]){
now++;
ajic[i][j] = now;
}
else now = 0;
}
}
for (int j = 1; j <= m; j++){
int now = 0;
for (int i = 1; i <= n; i++){
if (a[i][j]){
now++;
}
else{
if(now) mnh = min(mnh, now);
now = 0;
}
}
}
//cout << mnh << " " << mnw << endl;
/*for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
cout <<ajic[i][j] << " ";
}
cout << endl;
}*/
vector<pair<int, int> > v;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
if (a[i][j] == 1 && a[i - 1][j] == 0 && a[i][j - 1] == 0 && a[i - 1][j - 1] == 0){
int now = -1;
for (int ii = i; ii <= n; ii++){
if (now == -1 || ajic[ii][j] < now){
now = ajic[ii][j];
}
now = min(now, mnw);
v.push_back({ ii - i + 1, now });
}
}
if (a[i][j] == 1 && a[i][j - 1] == 0 && a[i + 1][j - 1] == 0 && a[i][j + 1] == 0){
int now = -1;
for (int ii = i; ii >= 1; ii--){
if (now == -1 || ajic[ii][j] < now){
now = ajic[ii][j];
}
now = min(now, mnw);
v.push_back({ i - ii + 1, now });
}
}
if (a[i][j] == 1 && a[i - 1][j] == 0 && a[i][j + 1] == 0 && a[i - 1][j + 1] == 0){
int now = -1;
for (int ii = i; ii <= n; ii++){
if (now == -1 || dzaxic[i][j] < now){
now = dzaxic[i][j];
}
now = min(now, mnw);
v.push_back({ ii - i + 1, now });
}
}
if (a[i][j] == 1 && a[i + 1][j] == 0 && a[i][j + 1] == 0 && a[i + 1][j + 1] == 0){
int now = -1;
for (int ii = i; ii >= 1; ii--){
if (now == -1 || dzaxic[ii][j] < now){
now = dzaxic[ii][j];
}
now = min(now, mnw);
v.push_back({ i - ii + 1, now });
}
}
}
}
memset(M, 63, sizeof M);
for (int i = 0; i < v.size(); i++){
int a = v[i].first;
int b = v[i].second;
M[a] = min(M[a], b);
}
long long ans = 0;
for (int i = 1; i <= n; i++){
long long a = i;
long long b = M[i];
a *= b;
ans = max(ans, a);
}
cout << ans << endl;
return 0;
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:35:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(now) mnw = min(mnw, now);
^~
bomb.cpp:36:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
now = 0;
^~~
bomb.cpp:55:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(now) mnh = min(mnh, now);
^~
bomb.cpp:56:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
now = 0;
^~~
bomb.cpp:113:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); i++){
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
3 |
Incorrect |
87 ms |
63424 KB |
Output isn't correct |
4 |
Incorrect |
98 ms |
63592 KB |
Output isn't correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
508 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
552 KB |
Output isn't correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
13 |
Correct |
2 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
632 KB |
Output is correct |
15 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
17 |
Correct |
2 ms |
1272 KB |
Output is correct |
18 |
Correct |
2 ms |
1016 KB |
Output is correct |
19 |
Incorrect |
2 ms |
1272 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
1276 KB |
Output isn't correct |
21 |
Correct |
2 ms |
760 KB |
Output is correct |
22 |
Correct |
2 ms |
1016 KB |
Output is correct |
23 |
Incorrect |
2 ms |
1272 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
1144 KB |
Output isn't correct |
25 |
Incorrect |
3 ms |
1528 KB |
Output isn't correct |
26 |
Incorrect |
3 ms |
1720 KB |
Output isn't correct |
27 |
Incorrect |
7 ms |
4984 KB |
Output isn't correct |
28 |
Incorrect |
6 ms |
2680 KB |
Output isn't correct |
29 |
Incorrect |
10 ms |
7032 KB |
Output isn't correct |
30 |
Incorrect |
9 ms |
5880 KB |
Output isn't correct |
31 |
Incorrect |
8 ms |
4372 KB |
Output isn't correct |
32 |
Incorrect |
8 ms |
5624 KB |
Output isn't correct |
33 |
Incorrect |
11 ms |
7032 KB |
Output isn't correct |
34 |
Incorrect |
5 ms |
2936 KB |
Output isn't correct |
35 |
Incorrect |
8 ms |
3704 KB |
Output isn't correct |
36 |
Incorrect |
10 ms |
8312 KB |
Output isn't correct |
37 |
Correct |
2 ms |
632 KB |
Output is correct |
38 |
Correct |
200 ms |
80280 KB |
Output is correct |
39 |
Correct |
2 ms |
636 KB |
Output is correct |
40 |
Incorrect |
33 ms |
20728 KB |
Output isn't correct |
41 |
Correct |
2 ms |
632 KB |
Output is correct |
42 |
Correct |
3 ms |
1656 KB |
Output is correct |
43 |
Incorrect |
271 ms |
109228 KB |
Output isn't correct |
44 |
Correct |
13 ms |
8440 KB |
Output is correct |
45 |
Correct |
219 ms |
94056 KB |
Output is correct |
46 |
Correct |
200 ms |
88296 KB |
Output is correct |
47 |
Correct |
222 ms |
94108 KB |
Output is correct |
48 |
Correct |
194 ms |
96516 KB |
Output is correct |
49 |
Incorrect |
177 ms |
80164 KB |
Output isn't correct |
50 |
Incorrect |
224 ms |
96504 KB |
Output isn't correct |
51 |
Incorrect |
213 ms |
96552 KB |
Output isn't correct |
52 |
Correct |
219 ms |
96468 KB |
Output is correct |
53 |
Incorrect |
199 ms |
87620 KB |
Output isn't correct |
54 |
Correct |
195 ms |
83192 KB |
Output is correct |
55 |
Incorrect |
187 ms |
73312 KB |
Output isn't correct |
56 |
Correct |
197 ms |
84328 KB |
Output is correct |
57 |
Incorrect |
172 ms |
64364 KB |
Output isn't correct |
58 |
Correct |
182 ms |
73464 KB |
Output is correct |
59 |
Correct |
176 ms |
70368 KB |
Output is correct |
60 |
Incorrect |
164 ms |
72032 KB |
Output isn't correct |
61 |
Incorrect |
168 ms |
80136 KB |
Output isn't correct |
62 |
Incorrect |
168 ms |
80124 KB |
Output isn't correct |
63 |
Incorrect |
166 ms |
80240 KB |
Output isn't correct |
64 |
Incorrect |
151 ms |
63016 KB |
Output isn't correct |
65 |
Correct |
204 ms |
87240 KB |
Output is correct |
66 |
Incorrect |
177 ms |
78068 KB |
Output isn't correct |
67 |
Correct |
223 ms |
96660 KB |
Output is correct |
68 |
Incorrect |
226 ms |
96524 KB |
Output isn't correct |
69 |
Correct |
179 ms |
63648 KB |
Output is correct |
70 |
Incorrect |
99 ms |
34040 KB |
Output isn't correct |
71 |
Incorrect |
151 ms |
48540 KB |
Output isn't correct |
72 |
Incorrect |
156 ms |
52344 KB |
Output isn't correct |
73 |
Incorrect |
153 ms |
52864 KB |
Output isn't correct |
74 |
Incorrect |
157 ms |
59600 KB |
Output isn't correct |
75 |
Incorrect |
159 ms |
61944 KB |
Output isn't correct |
76 |
Incorrect |
161 ms |
63068 KB |
Output isn't correct |
77 |
Incorrect |
159 ms |
63412 KB |
Output isn't correct |
78 |
Incorrect |
157 ms |
63736 KB |
Output isn't correct |
79 |
Incorrect |
137 ms |
36472 KB |
Output isn't correct |
80 |
Incorrect |
135 ms |
37788 KB |
Output isn't correct |
81 |
Incorrect |
134 ms |
38264 KB |
Output isn't correct |
82 |
Incorrect |
177 ms |
66608 KB |
Output isn't correct |
83 |
Incorrect |
160 ms |
66808 KB |
Output isn't correct |
84 |
Incorrect |
129 ms |
31824 KB |
Output isn't correct |
85 |
Incorrect |
154 ms |
65672 KB |
Output isn't correct |
86 |
Incorrect |
173 ms |
79324 KB |
Output isn't correct |
87 |
Incorrect |
154 ms |
64712 KB |
Output isn't correct |
88 |
Incorrect |
169 ms |
65440 KB |
Output isn't correct |
89 |
Incorrect |
172 ms |
74312 KB |
Output isn't correct |
90 |
Incorrect |
115 ms |
48348 KB |
Output isn't correct |
91 |
Incorrect |
167 ms |
69648 KB |
Output isn't correct |
92 |
Incorrect |
172 ms |
71160 KB |
Output isn't correct |
93 |
Incorrect |
171 ms |
78412 KB |
Output isn't correct |
94 |
Incorrect |
169 ms |
72980 KB |
Output isn't correct |
95 |
Incorrect |
161 ms |
66908 KB |
Output isn't correct |
96 |
Incorrect |
175 ms |
66396 KB |
Output isn't correct |
97 |
Incorrect |
168 ms |
79068 KB |
Output isn't correct |
98 |
Incorrect |
157 ms |
66168 KB |
Output isn't correct |
99 |
Incorrect |
175 ms |
72704 KB |
Output isn't correct |
100 |
Incorrect |
170 ms |
78024 KB |
Output isn't correct |