Submission #574044

# Submission time Handle Problem Language Result Execution time Memory
574044 2022-06-07T15:51:28 Z vovamr Bomb (IZhO17_bomb) C++17
90 / 100
683 ms 80280 KB
#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(m + 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] ? 1 + (!i ? 0 : dp1[i - 1][j]) : 0);
			}
			for (int i = n - 1; ~i; --i) {
				dp2[i][j] = (a[i][j] ? 1 + (i + 1 == n ? 0 : dp2[i + 1][j]) : 0);
			}
		}
 
		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 <= m; ++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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 708 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 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 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 324 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 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Incorrect 1 ms 468 KB Output isn't correct
27 Incorrect 4 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 2688 KB Output is correct
31 Correct 6 ms 2260 KB Output is correct
32 Correct 7 ms 2284 KB Output is correct
33 Correct 9 ms 2924 KB Output is correct
34 Correct 4 ms 1364 KB Output is correct
35 Correct 8 ms 2948 KB Output is correct
36 Incorrect 8 ms 2900 KB Output isn't correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 593 ms 80120 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 55 ms 10192 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 580 ms 80156 KB Output is correct
44 Correct 8 ms 2900 KB Output is correct
45 Correct 565 ms 80140 KB Output is correct
46 Correct 578 ms 80280 KB Output is correct
47 Correct 577 ms 80152 KB Output is correct
48 Correct 561 ms 80140 KB Output is correct
49 Incorrect 580 ms 80128 KB Output isn't correct
50 Correct 564 ms 80116 KB Output is correct
51 Correct 547 ms 80120 KB Output is correct
52 Correct 589 ms 80112 KB Output is correct
53 Correct 578 ms 80132 KB Output is correct
54 Correct 555 ms 80116 KB Output is correct
55 Correct 566 ms 80116 KB Output is correct
56 Correct 556 ms 80120 KB Output is correct
57 Correct 563 ms 80152 KB Output is correct
58 Correct 566 ms 80236 KB Output is correct
59 Correct 541 ms 80112 KB Output is correct
60 Incorrect 553 ms 80212 KB Output isn't correct
61 Incorrect 565 ms 80200 KB Output isn't correct
62 Incorrect 537 ms 80156 KB Output isn't correct
63 Incorrect 550 ms 80112 KB Output isn't correct
64 Incorrect 561 ms 80112 KB Output isn't correct
65 Correct 549 ms 80160 KB Output is correct
66 Correct 588 ms 80128 KB Output is correct
67 Correct 569 ms 80112 KB Output is correct
68 Correct 591 ms 80092 KB Output is correct
69 Correct 611 ms 80116 KB Output is correct
70 Correct 408 ms 51432 KB Output is correct
71 Correct 571 ms 80104 KB Output is correct
72 Correct 593 ms 80096 KB Output is correct
73 Correct 625 ms 80160 KB Output is correct
74 Correct 617 ms 80120 KB Output is correct
75 Correct 592 ms 80184 KB Output is correct
76 Correct 619 ms 80116 KB Output is correct
77 Correct 641 ms 80116 KB Output is correct
78 Correct 647 ms 80140 KB Output is correct
79 Correct 606 ms 80116 KB Output is correct
80 Correct 628 ms 80168 KB Output is correct
81 Correct 633 ms 80112 KB Output is correct
82 Correct 624 ms 80228 KB Output is correct
83 Correct 607 ms 80148 KB Output is correct
84 Correct 598 ms 80112 KB Output is correct
85 Correct 626 ms 80140 KB Output is correct
86 Correct 586 ms 80184 KB Output is correct
87 Correct 571 ms 80204 KB Output is correct
88 Correct 592 ms 80180 KB Output is correct
89 Correct 606 ms 80116 KB Output is correct
90 Correct 375 ms 51428 KB Output is correct
91 Correct 596 ms 80136 KB Output is correct
92 Correct 594 ms 80128 KB Output is correct
93 Correct 620 ms 80180 KB Output is correct
94 Correct 624 ms 80112 KB Output is correct
95 Correct 642 ms 80164 KB Output is correct
96 Correct 657 ms 80212 KB Output is correct
97 Correct 658 ms 80128 KB Output is correct
98 Correct 683 ms 80224 KB Output is correct
99 Correct 676 ms 80200 KB Output is correct
100 Correct 682 ms 80168 KB Output is correct