/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
const int N = 2505;
int n, m, a[N][N], pr[N][N], nxt[N][N], d[N], Y, X, ans;
int get(int sy, int sx, int y, int x)
{
sy--;
sx--;
if (sy == -1 || sx == -1)
return pr[y][x];
return pr[y][x] - pr[sy][x] - pr[y][sx] + pr[sy][sx];
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
char x;
scanf(" %c", &x);
a[i][j] += (x - '0');
pr[i][j] = a[i][j] + pr[i - 1][j] + pr[i][j - 1] - pr[i - 1][j - 1];
}
X = m;
Y = n;
for (int i = 1; i <= n; i++)
for (int j = m; j >= 1; j--)
{
if (a[i][j])
nxt[i][j] = nxt[i][j + 1] + 1;
else
nxt[i][j] = 0;
if (a[i][j - 1] == 0 && a[i][j])
X = min(X, nxt[i][j]);
}
for (int j = 1; j <= m; j++)
{
int y = 0;
for (int i = 1; i <= n; i++)
{
if (a[i][j])
y++;
else
y = 0;
if (a[i][j] && a[i + 1][j] == 0)
Y = min(y, Y);
}
}
for (int i = 1; i <= Y; i++)
d[i] = X;
for (int j = 1; j <= m; j++)
{
int y = 0, x = X;
for (int i = 1; i <= n; i++)
{
if (a[i][j] == 0)
{
y = 0;
x = X;
}
else
{
y++;
x = min(x, nxt[i][j]);
if (get(i - y + 1, j - 1, i, j - 1) != y)
d[y] = min(x, d[y]);
}
//cout << i << " : " << j << " = " << y << " : " << x << endl;
}
}
// for (int j = 1; j <= m; j++)
// {
// int y = 0, x = X;
// for (int i = n; i >= 1; i--)
// {
// if (a[i][j] == 0)
// {
// y = 0;
// x = X;
// }
// else
// {
// y++;
// x = min(x, nxt[i][j]);
// if (get(i, j - 1, i + y - 1, j - 1) != y)
// d[y] = min(x, d[y]);
// }
// //cout << i << " : " << j << " = " << y << " : " << x << endl;
// }
// }
for (int i = 1; i <= Y; i++)
{
//d[i + 1] = min(d[i + 1], d[i]);
//cout << i << " : " << d[i] << endl;
ans = max(ans, i * d[i]);
}
cout << ans << endl;
return 0;
}
/*
4 3
110
111
111
011
5 6
100000
111110
111110
111110
100000
6 5
00110
01110
11110
11011
11111
11111
9 9
000000000
000111000
000111000
011111110
011101110
011111110
000111000
000111000
000000000
9 9
000000000
000111000
000111000
011111110
011101110
011111110
000111000
000111000
000000000
6 6
000111
000111
001111
111100
111000
111000
6 6
111000
111000
111100
001111
000111
000111
6 6
000111
011111
011111
111000
111000
111000
*/
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:47:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %c", &x);
~~~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
37 ms |
30456 KB |
Output is correct |
4 |
Correct |
37 ms |
30456 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
10 |
Correct |
2 ms |
504 KB |
Output is correct |
11 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
508 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
16 |
Correct |
2 ms |
632 KB |
Output is correct |
17 |
Correct |
3 ms |
1144 KB |
Output is correct |
18 |
Correct |
3 ms |
1272 KB |
Output is correct |
19 |
Incorrect |
4 ms |
1528 KB |
Output isn't correct |
20 |
Incorrect |
4 ms |
1528 KB |
Output isn't correct |
21 |
Correct |
3 ms |
1016 KB |
Output is correct |
22 |
Correct |
3 ms |
1272 KB |
Output is correct |
23 |
Incorrect |
4 ms |
1588 KB |
Output isn't correct |
24 |
Incorrect |
3 ms |
1400 KB |
Output isn't correct |
25 |
Incorrect |
4 ms |
1656 KB |
Output isn't correct |
26 |
Correct |
4 ms |
1656 KB |
Output is correct |
27 |
Correct |
12 ms |
4932 KB |
Output is correct |
28 |
Incorrect |
14 ms |
5340 KB |
Output isn't correct |
29 |
Incorrect |
17 ms |
6648 KB |
Output isn't correct |
30 |
Incorrect |
21 ms |
7928 KB |
Output isn't correct |
31 |
Incorrect |
17 ms |
6268 KB |
Output isn't correct |
32 |
Incorrect |
18 ms |
7160 KB |
Output isn't correct |
33 |
Incorrect |
23 ms |
8440 KB |
Output isn't correct |
34 |
Incorrect |
12 ms |
5624 KB |
Output isn't correct |
35 |
Incorrect |
22 ms |
8312 KB |
Output isn't correct |
36 |
Correct |
24 ms |
8312 KB |
Output is correct |
37 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
38 |
Correct |
738 ms |
78968 KB |
Output is correct |
39 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
40 |
Incorrect |
92 ms |
20728 KB |
Output isn't correct |
41 |
Correct |
2 ms |
632 KB |
Output is correct |
42 |
Correct |
4 ms |
1656 KB |
Output is correct |
43 |
Correct |
669 ms |
79016 KB |
Output is correct |
44 |
Correct |
24 ms |
8312 KB |
Output is correct |
45 |
Incorrect |
670 ms |
79464 KB |
Output isn't correct |
46 |
Correct |
651 ms |
79352 KB |
Output is correct |
47 |
Incorrect |
660 ms |
78972 KB |
Output isn't correct |
48 |
Correct |
653 ms |
79004 KB |
Output is correct |
49 |
Correct |
741 ms |
78940 KB |
Output is correct |
50 |
Incorrect |
656 ms |
78668 KB |
Output isn't correct |
51 |
Incorrect |
650 ms |
78548 KB |
Output isn't correct |
52 |
Correct |
649 ms |
78584 KB |
Output is correct |
53 |
Incorrect |
645 ms |
78076 KB |
Output isn't correct |
54 |
Correct |
588 ms |
78428 KB |
Output is correct |
55 |
Incorrect |
584 ms |
78584 KB |
Output isn't correct |
56 |
Correct |
720 ms |
78584 KB |
Output is correct |
57 |
Incorrect |
593 ms |
78472 KB |
Output isn't correct |
58 |
Correct |
589 ms |
78448 KB |
Output is correct |
59 |
Correct |
585 ms |
78904 KB |
Output is correct |
60 |
Correct |
644 ms |
78620 KB |
Output is correct |
61 |
Correct |
738 ms |
78616 KB |
Output is correct |
62 |
Correct |
735 ms |
78556 KB |
Output is correct |
63 |
Correct |
732 ms |
79616 KB |
Output is correct |
64 |
Correct |
588 ms |
79224 KB |
Output is correct |
65 |
Correct |
671 ms |
79152 KB |
Output is correct |
66 |
Incorrect |
643 ms |
80104 KB |
Output isn't correct |
67 |
Correct |
672 ms |
79864 KB |
Output is correct |
68 |
Incorrect |
670 ms |
79480 KB |
Output isn't correct |
69 |
Correct |
584 ms |
80028 KB |
Output is correct |
70 |
Incorrect |
343 ms |
63088 KB |
Output isn't correct |
71 |
Incorrect |
548 ms |
78836 KB |
Output isn't correct |
72 |
Incorrect |
573 ms |
78904 KB |
Output isn't correct |
73 |
Incorrect |
585 ms |
80040 KB |
Output isn't correct |
74 |
Incorrect |
575 ms |
80112 KB |
Output isn't correct |
75 |
Incorrect |
578 ms |
80120 KB |
Output isn't correct |
76 |
Incorrect |
585 ms |
80112 KB |
Output isn't correct |
77 |
Incorrect |
599 ms |
80248 KB |
Output isn't correct |
78 |
Incorrect |
614 ms |
79992 KB |
Output isn't correct |
79 |
Incorrect |
549 ms |
80020 KB |
Output isn't correct |
80 |
Incorrect |
539 ms |
79944 KB |
Output isn't correct |
81 |
Incorrect |
516 ms |
80108 KB |
Output isn't correct |
82 |
Incorrect |
596 ms |
80152 KB |
Output isn't correct |
83 |
Incorrect |
601 ms |
79960 KB |
Output isn't correct |
84 |
Incorrect |
509 ms |
80124 KB |
Output isn't correct |
85 |
Incorrect |
591 ms |
80160 KB |
Output isn't correct |
86 |
Incorrect |
712 ms |
80080 KB |
Output isn't correct |
87 |
Incorrect |
576 ms |
80248 KB |
Output isn't correct |
88 |
Incorrect |
595 ms |
79776 KB |
Output isn't correct |
89 |
Incorrect |
627 ms |
79976 KB |
Output isn't correct |
90 |
Incorrect |
369 ms |
63176 KB |
Output isn't correct |
91 |
Incorrect |
619 ms |
80112 KB |
Output isn't correct |
92 |
Incorrect |
634 ms |
79868 KB |
Output isn't correct |
93 |
Incorrect |
709 ms |
79508 KB |
Output isn't correct |
94 |
Incorrect |
628 ms |
79624 KB |
Output isn't correct |
95 |
Incorrect |
592 ms |
79480 KB |
Output isn't correct |
96 |
Incorrect |
596 ms |
79440 KB |
Output isn't correct |
97 |
Incorrect |
731 ms |
79224 KB |
Output isn't correct |
98 |
Incorrect |
608 ms |
78980 KB |
Output isn't correct |
99 |
Incorrect |
622 ms |
78868 KB |
Output isn't correct |
100 |
Incorrect |
714 ms |
78884 KB |
Output isn't correct |