# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
556174 |
2022-05-02T14:37:42 Z |
ngpin04 |
Bomb (IZhO17_bomb) |
C++14 |
|
610 ms |
75656 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define TASK ""
#define ALL(x) (x).begin(), (x).end()
using namespace std;
template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
if (a < b) {a = b; return true;} return false;
}
const int N = 2505;
const int oo = 1e9;
const long long ooo = 1e18;
const int mod = 1e9 + 7; // 998244353;
const long double pi = acos(-1);
int up[N][N];
int dn[N][N];
int a[N][N];
int mx[N];
int n,m;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifdef ONLINE_JUDGE
// freopen(TASK".inp","r",stdin);
// freopen(TASK".out","w",stdout);
#endif
cin >> n >> m;
bool ok = false;
for (int i = 1; i <= n; i++) {
string str; cin >> str;
for (int j = 1; j <= m; j++) {
a[i][j] = str[j - 1] - '0';
ok |= a[i][j];
}
}
assert(ok);
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++)
if (a[i][j])
up[i][j] = up[i - 1][j] + 1;
for (int i = n; i >= 1; i--)
if (a[i][j])
dn[i][j] = dn[i + 1][j] + 1;
for (int i = 1; i <= n; i++)
if (a[i][j])
mini(mx[1], up[i][j] + dn[i][j] - 1);
}
for (int i = 1; i <= m; i++)
mx[i] = oo;
for (int t = 0; t < 2; t++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) if (a[i][j]) {
int k = j;
while (a[i][k])
k++;
int f = oo, g = oo;
for (int it = j; it < k; it++) {
mini(f, up[i][it]);
mini(g, dn[i][it]);
// cerr << i << " " << j << " " << it << " " << f << " " << g << "\n";
mini(mx[it - j + 1], f + g - 1);
}
mini(mx[k - j + 1], 0);
j = k;
}
}
for (int i = 1; i <= n; i++) {
reverse(a[i] + 1, a[i] + m + 1);
reverse(dn[i] + 1, dn[i] + m + 1);
reverse(up[i] + 1, up[i] + m + 1);
}
}
for (int i = 2; i <= m; i++)
mini(mx[i], mx[i - 1]);
int ans = 0;
for (int i = 1; i <= m; i++)
maxi(ans, i * mx[i]);
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
224 KB |
Output is correct |
2 |
Correct |
1 ms |
456 KB |
Output is correct |
3 |
Correct |
13 ms |
30420 KB |
Output is correct |
4 |
Correct |
13 ms |
30428 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
456 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
1108 KB |
Output is correct |
18 |
Correct |
1 ms |
1236 KB |
Output is correct |
19 |
Correct |
1 ms |
1484 KB |
Output is correct |
20 |
Correct |
1 ms |
1488 KB |
Output is correct |
21 |
Correct |
1 ms |
980 KB |
Output is correct |
22 |
Correct |
1 ms |
1236 KB |
Output is correct |
23 |
Correct |
1 ms |
1620 KB |
Output is correct |
24 |
Correct |
1 ms |
1364 KB |
Output is correct |
25 |
Correct |
1 ms |
1620 KB |
Output is correct |
26 |
Incorrect |
1 ms |
1620 KB |
Output isn't correct |
27 |
Incorrect |
4 ms |
4820 KB |
Output isn't correct |
28 |
Correct |
4 ms |
5164 KB |
Output is correct |
29 |
Correct |
6 ms |
6612 KB |
Output is correct |
30 |
Correct |
6 ms |
7892 KB |
Output is correct |
31 |
Correct |
5 ms |
6228 KB |
Output is correct |
32 |
Correct |
5 ms |
7252 KB |
Output is correct |
33 |
Correct |
7 ms |
8364 KB |
Output is correct |
34 |
Correct |
4 ms |
5588 KB |
Output is correct |
35 |
Correct |
6 ms |
8300 KB |
Output is correct |
36 |
Incorrect |
11 ms |
8360 KB |
Output isn't correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Correct |
427 ms |
74708 KB |
Output is correct |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Correct |
59 ms |
20172 KB |
Output is correct |
41 |
Correct |
1 ms |
468 KB |
Output is correct |
42 |
Correct |
1 ms |
1620 KB |
Output is correct |
43 |
Correct |
377 ms |
74524 KB |
Output is correct |
44 |
Correct |
7 ms |
8360 KB |
Output is correct |
45 |
Correct |
363 ms |
74384 KB |
Output is correct |
46 |
Correct |
338 ms |
74676 KB |
Output is correct |
47 |
Correct |
369 ms |
74512 KB |
Output is correct |
48 |
Correct |
329 ms |
74404 KB |
Output is correct |
49 |
Incorrect |
481 ms |
74572 KB |
Output isn't correct |
50 |
Correct |
367 ms |
74496 KB |
Output is correct |
51 |
Correct |
367 ms |
74448 KB |
Output is correct |
52 |
Correct |
342 ms |
74520 KB |
Output is correct |
53 |
Correct |
368 ms |
74396 KB |
Output is correct |
54 |
Correct |
278 ms |
74444 KB |
Output is correct |
55 |
Correct |
295 ms |
74488 KB |
Output is correct |
56 |
Correct |
524 ms |
74584 KB |
Output is correct |
57 |
Correct |
282 ms |
74492 KB |
Output is correct |
58 |
Correct |
359 ms |
74968 KB |
Output is correct |
59 |
Correct |
341 ms |
75012 KB |
Output is correct |
60 |
Incorrect |
413 ms |
75496 KB |
Output isn't correct |
61 |
Incorrect |
573 ms |
75624 KB |
Output isn't correct |
62 |
Incorrect |
610 ms |
75656 KB |
Output isn't correct |
63 |
Incorrect |
604 ms |
75532 KB |
Output isn't correct |
64 |
Incorrect |
332 ms |
75468 KB |
Output isn't correct |
65 |
Correct |
400 ms |
75508 KB |
Output is correct |
66 |
Correct |
427 ms |
75448 KB |
Output is correct |
67 |
Correct |
410 ms |
75464 KB |
Output is correct |
68 |
Correct |
466 ms |
75512 KB |
Output is correct |
69 |
Correct |
351 ms |
75316 KB |
Output is correct |
70 |
Correct |
174 ms |
60284 KB |
Output is correct |
71 |
Correct |
243 ms |
75288 KB |
Output is correct |
72 |
Correct |
322 ms |
75188 KB |
Output is correct |
73 |
Correct |
287 ms |
75212 KB |
Output is correct |
74 |
Correct |
328 ms |
75356 KB |
Output is correct |
75 |
Correct |
323 ms |
75224 KB |
Output is correct |
76 |
Correct |
313 ms |
75284 KB |
Output is correct |
77 |
Correct |
316 ms |
75264 KB |
Output is correct |
78 |
Correct |
327 ms |
75292 KB |
Output is correct |
79 |
Correct |
237 ms |
75232 KB |
Output is correct |
80 |
Correct |
255 ms |
75192 KB |
Output is correct |
81 |
Correct |
225 ms |
75008 KB |
Output is correct |
82 |
Correct |
346 ms |
75200 KB |
Output is correct |
83 |
Correct |
324 ms |
75056 KB |
Output is correct |
84 |
Correct |
239 ms |
75012 KB |
Output is correct |
85 |
Correct |
310 ms |
75088 KB |
Output is correct |
86 |
Correct |
524 ms |
75184 KB |
Output is correct |
87 |
Correct |
328 ms |
75064 KB |
Output is correct |
88 |
Correct |
317 ms |
75172 KB |
Output is correct |
89 |
Correct |
381 ms |
75060 KB |
Output is correct |
90 |
Correct |
203 ms |
60312 KB |
Output is correct |
91 |
Correct |
365 ms |
75164 KB |
Output is correct |
92 |
Correct |
399 ms |
75316 KB |
Output is correct |
93 |
Correct |
510 ms |
75052 KB |
Output is correct |
94 |
Correct |
411 ms |
75112 KB |
Output is correct |
95 |
Correct |
330 ms |
75156 KB |
Output is correct |
96 |
Correct |
327 ms |
75280 KB |
Output is correct |
97 |
Correct |
525 ms |
75292 KB |
Output is correct |
98 |
Correct |
331 ms |
75272 KB |
Output is correct |
99 |
Correct |
395 ms |
75360 KB |
Output is correct |
100 |
Correct |
543 ms |
75380 KB |
Output is correct |