#include <bits/stdc++.h>
#define all(i) (i).begin(), (i).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl
using namespace std;
template<typename T1, typename T2>
ostream& operator << (ostream &i, pair<T1, T2> j) {
return i << j.first << ' ' << j.second;
}
template<typename T>
ostream& operator << (ostream &i, vector<T> j) {
i << '{' << j.size() << ':';
for (T ii : j) i << ' ' << ii;
return i << '}';
}
typedef long long ll;
typedef pair<int, int> pi;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n, m;
cin >> n >> m;
vector<string> v(n + 2, string(m + 2, '0'));
for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) cin >> v[i][j];
vector<vector<int>> h(n + 2, vector<int>(m + 2, 0)), w(n + 2, vector<int>(m + 2, 0));
int _h = n, _w = m;
for (int i = n; i; --i) for (int j = m; j; --j) if (v[i][j] == '1') {
h[i][j] = h[i + 1][j] + 1, w[i][j] = w[i][j + 1] + 1;
if (v[i - 1][j] == '0') _h = min(_h, h[i][j]);
if (v[i][j - 1] == '0') _w = min(_w, w[i][j]);
}
vector<int> lim(_h + 2, _w);
for (int i = 1; i <= n; ++i) {
pi pre(0, 0);
for (int j = 1; j <= m + 1; ++j) {
if (v[i - 1][j] == '0' && v[i][j - 1] == '0') {
pre = pi(j, h[i][j]);
continue;
}
if (h[i][j] >= pre.second) continue;
lim[h[i][j] + 1] = min(lim[h[i][j] + 1], j - pre.first);
pre.second = h[i][j];
}
}
int ans = 0;
for (int i = 1; i <= _h; ++i) lim[i] = min(lim[i], lim[i - 1]), ans = max(ans, i * lim[i]);
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
2 ms |
588 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
25 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Runtime error |
3 ms |
972 KB |
Execution killed with signal 6 |
28 |
Incorrect |
3 ms |
1228 KB |
Output isn't correct |
29 |
Runtime error |
5 ms |
2756 KB |
Execution killed with signal 6 |
30 |
Incorrect |
5 ms |
2036 KB |
Output isn't correct |
31 |
Incorrect |
4 ms |
1612 KB |
Output isn't correct |
32 |
Incorrect |
4 ms |
1740 KB |
Output isn't correct |
33 |
Incorrect |
5 ms |
2124 KB |
Output isn't correct |
34 |
Runtime error |
4 ms |
1996 KB |
Execution killed with signal 6 |
35 |
Incorrect |
5 ms |
2072 KB |
Output isn't correct |
36 |
Correct |
6 ms |
2124 KB |
Output is correct |
37 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
38 |
Correct |
149 ms |
55808 KB |
Output is correct |
39 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
40 |
Incorrect |
19 ms |
7244 KB |
Output isn't correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
332 KB |
Output is correct |
43 |
Runtime error |
192 ms |
112652 KB |
Execution killed with signal 11 |
44 |
Correct |
6 ms |
2124 KB |
Output is correct |
45 |
Incorrect |
141 ms |
55684 KB |
Output isn't correct |
46 |
Correct |
144 ms |
55696 KB |
Output is correct |
47 |
Incorrect |
142 ms |
55692 KB |
Output isn't correct |
48 |
Runtime error |
199 ms |
112764 KB |
Execution killed with signal 6 |
49 |
Correct |
151 ms |
55676 KB |
Output is correct |
50 |
Runtime error |
204 ms |
112768 KB |
Execution killed with signal 6 |
51 |
Runtime error |
202 ms |
112708 KB |
Execution killed with signal 6 |
52 |
Runtime error |
197 ms |
112636 KB |
Execution killed with signal 11 |
53 |
Runtime error |
201 ms |
112836 KB |
Execution killed with signal 6 |
54 |
Runtime error |
194 ms |
112780 KB |
Execution killed with signal 6 |
55 |
Runtime error |
194 ms |
112788 KB |
Execution killed with signal 6 |
56 |
Correct |
152 ms |
55688 KB |
Output is correct |
57 |
Runtime error |
192 ms |
112788 KB |
Execution killed with signal 6 |
58 |
Runtime error |
193 ms |
112772 KB |
Execution killed with signal 6 |
59 |
Runtime error |
194 ms |
112708 KB |
Execution killed with signal 6 |
60 |
Correct |
141 ms |
55696 KB |
Output is correct |
61 |
Correct |
149 ms |
55624 KB |
Output is correct |
62 |
Correct |
148 ms |
55596 KB |
Output is correct |
63 |
Correct |
151 ms |
55752 KB |
Output is correct |
64 |
Correct |
133 ms |
55680 KB |
Output is correct |
65 |
Runtime error |
201 ms |
112776 KB |
Execution killed with signal 6 |
66 |
Incorrect |
139 ms |
55692 KB |
Output isn't correct |
67 |
Runtime error |
202 ms |
112836 KB |
Execution killed with signal 6 |
68 |
Runtime error |
200 ms |
112780 KB |
Execution killed with signal 6 |
69 |
Runtime error |
193 ms |
112708 KB |
Execution killed with signal 6 |
70 |
Incorrect |
86 ms |
35936 KB |
Output isn't correct |
71 |
Incorrect |
130 ms |
55620 KB |
Output isn't correct |
72 |
Incorrect |
135 ms |
55688 KB |
Output isn't correct |
73 |
Incorrect |
133 ms |
55680 KB |
Output isn't correct |
74 |
Incorrect |
135 ms |
55748 KB |
Output isn't correct |
75 |
Incorrect |
134 ms |
55692 KB |
Output isn't correct |
76 |
Incorrect |
136 ms |
55688 KB |
Output isn't correct |
77 |
Incorrect |
135 ms |
55684 KB |
Output isn't correct |
78 |
Incorrect |
137 ms |
55748 KB |
Output isn't correct |
79 |
Incorrect |
126 ms |
55620 KB |
Output isn't correct |
80 |
Incorrect |
129 ms |
55696 KB |
Output isn't correct |
81 |
Incorrect |
127 ms |
55700 KB |
Output isn't correct |
82 |
Incorrect |
138 ms |
55748 KB |
Output isn't correct |
83 |
Incorrect |
135 ms |
55680 KB |
Output isn't correct |
84 |
Incorrect |
126 ms |
55680 KB |
Output isn't correct |
85 |
Incorrect |
133 ms |
55624 KB |
Output isn't correct |
86 |
Incorrect |
146 ms |
55692 KB |
Output isn't correct |
87 |
Incorrect |
133 ms |
55684 KB |
Output isn't correct |
88 |
Incorrect |
136 ms |
55620 KB |
Output isn't correct |
89 |
Incorrect |
138 ms |
55648 KB |
Output isn't correct |
90 |
Incorrect |
88 ms |
35864 KB |
Output isn't correct |
91 |
Incorrect |
157 ms |
55684 KB |
Output isn't correct |
92 |
Incorrect |
138 ms |
55680 KB |
Output isn't correct |
93 |
Incorrect |
146 ms |
55676 KB |
Output isn't correct |
94 |
Incorrect |
138 ms |
55688 KB |
Output isn't correct |
95 |
Incorrect |
135 ms |
55748 KB |
Output isn't correct |
96 |
Incorrect |
137 ms |
55748 KB |
Output isn't correct |
97 |
Incorrect |
146 ms |
55692 KB |
Output isn't correct |
98 |
Incorrect |
135 ms |
55676 KB |
Output isn't correct |
99 |
Incorrect |
144 ms |
55620 KB |
Output isn't correct |
100 |
Incorrect |
148 ms |
55688 KB |
Output isn't correct |