#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define ll long long
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mpp make_pair
#define ve vector
using namespace std;
using namespace __gnu_pbds;
template<class T> using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll inf = 1e18; const int iinf = 1e9;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> inline bool chmin(T& a, T b) { return (a > b ? a = b, 1 : 0); }
template <typename T> inline bool chmax(T& a, T b) { return (a < b ? a = b, 1 : 0); }
inline void solve() {
int n, m;
cin >> n >> m;
ve<ve<int>> a(n, ve<int>(m));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
char x;
cin >> x;
a[i][j] = x - '0';
}
}
ve<int> mx(n + 2, iinf);
for (int rep = 0; rep < 2; ++rep) {
ve<ve<int>> dp1(n, ve<int> (m)), dp2(n, ve<int> (m));
for (int j = 0; j < m; ++j) {
for (int i = 0; i < n; ++i) {
dp1[i][j] = a[i][j];
if (i && a[i - 1][j] && a[i][j]) dp1[i][j] += dp1[i - 1][j];
}
for (int i = n - 1; ~i; --i) {
dp2[i][j] = a[i][j];
if (i + 1 < n && a[i + 1][j] && a[i][j]) dp2[i][j] += dp2[i + 1][j];
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ) {
if (!a[i][j]) { ++j; continue; }
int p = j;
while (j < m && a[i][p]) ++p;
int a = iinf, b = iinf;
for (int k = j; k < p; ++k) {
chmin(a, dp1[i][k]);
chmin(b, dp2[i][k]);
chmin(mx[k - j + 1], a + b - 1);
}
chmin(mx[p - j + 1], 0);
j = p;
}
}
for (int i = 0; i < n; ++i) reverse(all(a[i]));
}
ll ans = 0;
for (int i = 1; i <= n; ++i) {
chmin(mx[i], mx[i - 1]);
chmax(ans, i * 1ll * mx[i]);
}
cout << ans;
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int q = 1; // cin >> q;
while (q--) solve();
cerr << fixed << setprecision(3) << "Time execution: " << (double)clock() / CLOCKS_PER_SEC << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
752 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
5 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
6 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
216 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
328 KB |
Output is correct |
17 |
Correct |
1 ms |
328 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
456 KB |
Output is correct |
26 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
27 |
Incorrect |
5 ms |
1364 KB |
Output isn't correct |
28 |
Correct |
5 ms |
1748 KB |
Output is correct |
29 |
Correct |
6 ms |
1892 KB |
Output is correct |
30 |
Correct |
8 ms |
2708 KB |
Output is correct |
31 |
Correct |
6 ms |
2260 KB |
Output is correct |
32 |
Correct |
7 ms |
2276 KB |
Output is correct |
33 |
Correct |
9 ms |
2952 KB |
Output is correct |
34 |
Correct |
4 ms |
1360 KB |
Output is correct |
35 |
Correct |
8 ms |
2924 KB |
Output is correct |
36 |
Incorrect |
9 ms |
2888 KB |
Output isn't correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
618 ms |
74556 KB |
Output is correct |
39 |
Correct |
0 ms |
328 KB |
Output is correct |
40 |
Runtime error |
46 ms |
19240 KB |
Execution killed with signal 11 |
41 |
Correct |
1 ms |
328 KB |
Output is correct |
42 |
Correct |
1 ms |
468 KB |
Output is correct |
43 |
Correct |
595 ms |
74540 KB |
Output is correct |
44 |
Correct |
10 ms |
2952 KB |
Output is correct |
45 |
Correct |
586 ms |
74568 KB |
Output is correct |
46 |
Correct |
603 ms |
74516 KB |
Output is correct |
47 |
Correct |
628 ms |
74512 KB |
Output is correct |
48 |
Correct |
601 ms |
74636 KB |
Output is correct |
49 |
Incorrect |
585 ms |
74636 KB |
Output isn't correct |
50 |
Correct |
580 ms |
74424 KB |
Output is correct |
51 |
Correct |
585 ms |
74512 KB |
Output is correct |
52 |
Correct |
603 ms |
74608 KB |
Output is correct |
53 |
Correct |
560 ms |
74608 KB |
Output is correct |
54 |
Correct |
601 ms |
74516 KB |
Output is correct |
55 |
Correct |
578 ms |
74576 KB |
Output is correct |
56 |
Correct |
605 ms |
74568 KB |
Output is correct |
57 |
Correct |
578 ms |
74484 KB |
Output is correct |
58 |
Correct |
568 ms |
74512 KB |
Output is correct |
59 |
Correct |
579 ms |
74556 KB |
Output is correct |
60 |
Incorrect |
581 ms |
74520 KB |
Output isn't correct |
61 |
Incorrect |
586 ms |
74624 KB |
Output isn't correct |
62 |
Incorrect |
603 ms |
74528 KB |
Output isn't correct |
63 |
Incorrect |
603 ms |
74428 KB |
Output isn't correct |
64 |
Incorrect |
596 ms |
74588 KB |
Output isn't correct |
65 |
Correct |
593 ms |
74512 KB |
Output is correct |
66 |
Correct |
594 ms |
74580 KB |
Output is correct |
67 |
Correct |
590 ms |
74428 KB |
Output is correct |
68 |
Correct |
588 ms |
74616 KB |
Output is correct |
69 |
Correct |
583 ms |
74516 KB |
Output is correct |
70 |
Correct |
350 ms |
47984 KB |
Output is correct |
71 |
Correct |
568 ms |
74560 KB |
Output is correct |
72 |
Correct |
575 ms |
74740 KB |
Output is correct |
73 |
Correct |
580 ms |
74560 KB |
Output is correct |
74 |
Correct |
575 ms |
74512 KB |
Output is correct |
75 |
Correct |
565 ms |
74592 KB |
Output is correct |
76 |
Correct |
598 ms |
74512 KB |
Output is correct |
77 |
Correct |
577 ms |
74572 KB |
Output is correct |
78 |
Correct |
583 ms |
74516 KB |
Output is correct |
79 |
Correct |
579 ms |
74604 KB |
Output is correct |
80 |
Correct |
581 ms |
74588 KB |
Output is correct |
81 |
Correct |
580 ms |
74548 KB |
Output is correct |
82 |
Correct |
588 ms |
74552 KB |
Output is correct |
83 |
Correct |
584 ms |
74532 KB |
Output is correct |
84 |
Correct |
586 ms |
74496 KB |
Output is correct |
85 |
Correct |
580 ms |
74580 KB |
Output is correct |
86 |
Correct |
584 ms |
74568 KB |
Output is correct |
87 |
Correct |
592 ms |
74512 KB |
Output is correct |
88 |
Correct |
580 ms |
74432 KB |
Output is correct |
89 |
Correct |
591 ms |
74560 KB |
Output is correct |
90 |
Correct |
355 ms |
48076 KB |
Output is correct |
91 |
Correct |
557 ms |
74532 KB |
Output is correct |
92 |
Correct |
598 ms |
74528 KB |
Output is correct |
93 |
Correct |
599 ms |
74512 KB |
Output is correct |
94 |
Correct |
592 ms |
74520 KB |
Output is correct |
95 |
Correct |
581 ms |
74548 KB |
Output is correct |
96 |
Correct |
591 ms |
74504 KB |
Output is correct |
97 |
Correct |
577 ms |
74528 KB |
Output is correct |
98 |
Correct |
571 ms |
74776 KB |
Output is correct |
99 |
Correct |
595 ms |
74604 KB |
Output is correct |
100 |
Correct |
593 ms |
74564 KB |
Output is correct |