/*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], lst[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 i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (a[i][j])
lst[i][j] = lst[i][j - 1] + 1;
else
lst[i][j] = 0;
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, l = X, r = X;
for (int i = 1; i <= n; i++)
{
if (a[i][j] == 0)
{
y = 0;
l = r = X;
}
else
{
y++;
r = min(r, nxt[i][j]);
l = min(l, lst[i][j]);
d[y] = min(l + r - 1, d[y]);
}
//cout << i << " : " << j << " = " << y << " : " << x << endl;
}
}
for (int j = 1; j <= m; j++)
{
int y = 0, l = X, r = X;
for (int i = n; i >= 1; i--)
{
if (a[i][j] == 0)
{
y = 0;
l = r = X;
}
else
{
y++;
r = min(r, nxt[i][j]);
l = min(l, lst[i][j]);
d[y] = min(l + r - 1, 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
000000
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 |
632 KB |
Output is correct |
3 |
Correct |
49 ms |
40572 KB |
Output is correct |
4 |
Correct |
49 ms |
40568 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 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
2 ms |
632 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 |
632 KB |
Output is correct |
15 |
Correct |
2 ms |
632 KB |
Output is correct |
16 |
Correct |
2 ms |
636 KB |
Output is correct |
17 |
Correct |
3 ms |
1528 KB |
Output is correct |
18 |
Correct |
3 ms |
1528 KB |
Output is correct |
19 |
Correct |
4 ms |
2040 KB |
Output is correct |
20 |
Correct |
4 ms |
1912 KB |
Output is correct |
21 |
Correct |
3 ms |
1272 KB |
Output is correct |
22 |
Correct |
4 ms |
1656 KB |
Output is correct |
23 |
Correct |
4 ms |
2044 KB |
Output is correct |
24 |
Correct |
3 ms |
1784 KB |
Output is correct |
25 |
Correct |
4 ms |
2040 KB |
Output is correct |
26 |
Correct |
4 ms |
2040 KB |
Output is correct |
27 |
Correct |
14 ms |
6264 KB |
Output is correct |
28 |
Correct |
14 ms |
6776 KB |
Output is correct |
29 |
Correct |
18 ms |
8568 KB |
Output is correct |
30 |
Correct |
23 ms |
10232 KB |
Output is correct |
31 |
Correct |
18 ms |
8056 KB |
Output is correct |
32 |
Correct |
20 ms |
9336 KB |
Output is correct |
33 |
Correct |
24 ms |
10744 KB |
Output is correct |
34 |
Correct |
13 ms |
7288 KB |
Output is correct |
35 |
Correct |
23 ms |
10744 KB |
Output is correct |
36 |
Correct |
29 ms |
10744 KB |
Output is correct |
37 |
Correct |
2 ms |
632 KB |
Output is correct |
38 |
Correct |
973 ms |
98508 KB |
Output is correct |
39 |
Correct |
2 ms |
632 KB |
Output is correct |
40 |
Correct |
119 ms |
26380 KB |
Output is correct |
41 |
Correct |
2 ms |
632 KB |
Output is correct |
42 |
Correct |
4 ms |
2040 KB |
Output is correct |
43 |
Correct |
847 ms |
98652 KB |
Output is correct |
44 |
Correct |
25 ms |
10744 KB |
Output is correct |
45 |
Correct |
831 ms |
98424 KB |
Output is correct |
46 |
Correct |
787 ms |
98424 KB |
Output is correct |
47 |
Correct |
832 ms |
98448 KB |
Output is correct |
48 |
Correct |
803 ms |
98584 KB |
Output is correct |
49 |
Correct |
962 ms |
98552 KB |
Output is correct |
50 |
Correct |
818 ms |
98496 KB |
Output is correct |
51 |
Correct |
815 ms |
98652 KB |
Output is correct |
52 |
Correct |
810 ms |
98524 KB |
Output is correct |
53 |
Correct |
815 ms |
98416 KB |
Output is correct |
54 |
Correct |
688 ms |
98524 KB |
Output is correct |
55 |
Correct |
681 ms |
98424 KB |
Output is correct |
56 |
Correct |
990 ms |
98552 KB |
Output is correct |
57 |
Correct |
676 ms |
98552 KB |
Output is correct |
58 |
Correct |
676 ms |
98428 KB |
Output is correct |
59 |
Correct |
693 ms |
98424 KB |
Output is correct |
60 |
Correct |
790 ms |
98420 KB |
Output is correct |
61 |
Execution timed out |
1061 ms |
98552 KB |
Time limit exceeded |
62 |
Correct |
963 ms |
98488 KB |
Output is correct |
63 |
Correct |
963 ms |
98424 KB |
Output is correct |
64 |
Correct |
726 ms |
98408 KB |
Output is correct |
65 |
Correct |
805 ms |
98608 KB |
Output is correct |
66 |
Correct |
800 ms |
98368 KB |
Output is correct |
67 |
Correct |
844 ms |
98552 KB |
Output is correct |
68 |
Correct |
855 ms |
98680 KB |
Output is correct |
69 |
Correct |
679 ms |
98336 KB |
Output is correct |
70 |
Correct |
370 ms |
78840 KB |
Output is correct |
71 |
Correct |
613 ms |
98664 KB |
Output is correct |
72 |
Correct |
711 ms |
98424 KB |
Output is correct |
73 |
Correct |
710 ms |
98424 KB |
Output is correct |
74 |
Correct |
668 ms |
98492 KB |
Output is correct |
75 |
Correct |
677 ms |
98516 KB |
Output is correct |
76 |
Correct |
684 ms |
98428 KB |
Output is correct |
77 |
Correct |
696 ms |
98624 KB |
Output is correct |
78 |
Correct |
712 ms |
98508 KB |
Output is correct |
79 |
Correct |
539 ms |
98484 KB |
Output is correct |
80 |
Correct |
536 ms |
98424 KB |
Output is correct |
81 |
Correct |
551 ms |
98416 KB |
Output is correct |
82 |
Correct |
701 ms |
98652 KB |
Output is correct |
83 |
Correct |
705 ms |
98492 KB |
Output is correct |
84 |
Correct |
546 ms |
98424 KB |
Output is correct |
85 |
Correct |
696 ms |
98408 KB |
Output is correct |
86 |
Correct |
926 ms |
98396 KB |
Output is correct |
87 |
Correct |
678 ms |
98452 KB |
Output is correct |
88 |
Correct |
705 ms |
98480 KB |
Output is correct |
89 |
Correct |
821 ms |
98452 KB |
Output is correct |
90 |
Correct |
437 ms |
78944 KB |
Output is correct |
91 |
Correct |
732 ms |
98424 KB |
Output is correct |
92 |
Correct |
778 ms |
98448 KB |
Output is correct |
93 |
Correct |
921 ms |
98552 KB |
Output is correct |
94 |
Correct |
771 ms |
98464 KB |
Output is correct |
95 |
Correct |
700 ms |
98428 KB |
Output is correct |
96 |
Correct |
713 ms |
98608 KB |
Output is correct |
97 |
Correct |
925 ms |
98592 KB |
Output is correct |
98 |
Correct |
706 ms |
98548 KB |
Output is correct |
99 |
Correct |
763 ms |
98548 KB |
Output is correct |
100 |
Correct |
929 ms |
98636 KB |
Output is correct |