# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
43151 |
2018-03-09T15:02:01 Z |
cheater2k |
Bomb (IZhO17_bomb) |
C++14 |
|
822 ms |
131072 KB |
/*
5 5
00111
00111
11111
11110
11100
*/
#include <bits/stdc++.h>
using namespace std;
#define left __left
#define right __right
const int N = 2505;
int n, m, nrow, ncol;
int left[N][N];
int right[N][N];
int up[N][N];
int down[N][N];
char a[N][N];
int c[N];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) left[i][j] = a[i][j] == '1' ? left[i][j - 1] + 1 : 0;
for (int j = m; j >= 1; --j) right[i][j] = a[i][j] == '1' ? right[i][j + 1] + 1 : 0;
}
for (int j = 1; j <= m; ++j) {
for (int i = 1; i <= n; ++i) up[i][j] = a[i][j] == '1' ? up[i - 1][j] + 1 : 0;
for (int i = n; i >= 1; --i) down[i][j] = a[i][j] == '1' ? down[i + 1][j] + 1 : 0;
}
nrow = n, ncol = m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) if (a[i][j] == '1') {
nrow = min(nrow, up[i][j] + down[i][j] - 1);
ncol = min(ncol, left[i][j] + right[i][j] - 1);
}
}
int res = 0;
for (int r = 1; r <= nrow; ++r) c[r] = ncol;
for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) {
if (a[i][j] != '1') continue;
int minleft = ncol;
int minright = ncol;
if (down[i][j] == 1) {
for (int k = i; k >= i - nrow + 1; --k) {
minleft = min(minleft, left[k][j]);
minright = min(minright, right[k][j]);
c[i - k + 1] = min(c[i - k + 1], minleft + minright - 1);
}
}
minleft = minright = ncol;
if (up[i][j] == 1) {
for (int k = i; k <= i + nrow - 1; ++k) {
minleft = min(minleft, left[k][j]);
minright = min(minright, right[k][j]);
c[k - i + 1] = min(c[k - i + 1], minleft + minright - 1);
}
}
}
for (int r = 1; r <= nrow; ++r) res = max(res, r * c[r]);
cout << res << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
740 KB |
Output is correct |
3 |
Correct |
36 ms |
46640 KB |
Output is correct |
4 |
Correct |
36 ms |
46668 KB |
Output is correct |
5 |
Correct |
2 ms |
46668 KB |
Output is correct |
6 |
Correct |
2 ms |
46668 KB |
Output is correct |
7 |
Correct |
2 ms |
46668 KB |
Output is correct |
8 |
Correct |
2 ms |
46668 KB |
Output is correct |
9 |
Correct |
2 ms |
46668 KB |
Output is correct |
10 |
Correct |
1 ms |
46668 KB |
Output is correct |
11 |
Correct |
2 ms |
46668 KB |
Output is correct |
12 |
Correct |
2 ms |
46668 KB |
Output is correct |
13 |
Correct |
2 ms |
46668 KB |
Output is correct |
14 |
Correct |
2 ms |
46668 KB |
Output is correct |
15 |
Correct |
2 ms |
46668 KB |
Output is correct |
16 |
Correct |
2 ms |
46668 KB |
Output is correct |
17 |
Correct |
2 ms |
46668 KB |
Output is correct |
18 |
Correct |
2 ms |
46668 KB |
Output is correct |
19 |
Correct |
4 ms |
46668 KB |
Output is correct |
20 |
Correct |
3 ms |
46668 KB |
Output is correct |
21 |
Correct |
2 ms |
46668 KB |
Output is correct |
22 |
Correct |
3 ms |
46668 KB |
Output is correct |
23 |
Correct |
3 ms |
46668 KB |
Output is correct |
24 |
Correct |
3 ms |
46668 KB |
Output is correct |
25 |
Correct |
3 ms |
46668 KB |
Output is correct |
26 |
Correct |
3 ms |
46668 KB |
Output is correct |
27 |
Correct |
12 ms |
46668 KB |
Output is correct |
28 |
Correct |
9 ms |
46668 KB |
Output is correct |
29 |
Correct |
11 ms |
46668 KB |
Output is correct |
30 |
Correct |
19 ms |
46668 KB |
Output is correct |
31 |
Correct |
15 ms |
46668 KB |
Output is correct |
32 |
Correct |
13 ms |
46668 KB |
Output is correct |
33 |
Correct |
16 ms |
46668 KB |
Output is correct |
34 |
Correct |
8 ms |
46668 KB |
Output is correct |
35 |
Correct |
13 ms |
46668 KB |
Output is correct |
36 |
Correct |
17 ms |
46668 KB |
Output is correct |
37 |
Correct |
2 ms |
46668 KB |
Output is correct |
38 |
Correct |
776 ms |
112820 KB |
Output is correct |
39 |
Correct |
2 ms |
112820 KB |
Output is correct |
40 |
Correct |
68 ms |
112820 KB |
Output is correct |
41 |
Correct |
2 ms |
112820 KB |
Output is correct |
42 |
Correct |
3 ms |
112820 KB |
Output is correct |
43 |
Correct |
486 ms |
119708 KB |
Output is correct |
44 |
Correct |
16 ms |
119708 KB |
Output is correct |
45 |
Correct |
580 ms |
125800 KB |
Output is correct |
46 |
Correct |
516 ms |
131072 KB |
Output is correct |
47 |
Correct |
590 ms |
131072 KB |
Output is correct |
48 |
Correct |
452 ms |
131072 KB |
Output is correct |
49 |
Correct |
466 ms |
131072 KB |
Output is correct |
50 |
Correct |
442 ms |
131072 KB |
Output is correct |
51 |
Correct |
437 ms |
131072 KB |
Output is correct |
52 |
Correct |
482 ms |
131072 KB |
Output is correct |
53 |
Correct |
447 ms |
131072 KB |
Output is correct |
54 |
Correct |
448 ms |
131072 KB |
Output is correct |
55 |
Correct |
436 ms |
131072 KB |
Output is correct |
56 |
Correct |
822 ms |
131072 KB |
Output is correct |
57 |
Correct |
446 ms |
131072 KB |
Output is correct |
58 |
Correct |
433 ms |
131072 KB |
Output is correct |
59 |
Correct |
452 ms |
131072 KB |
Output is correct |
60 |
Correct |
439 ms |
131072 KB |
Output is correct |
61 |
Correct |
465 ms |
131072 KB |
Output is correct |
62 |
Correct |
546 ms |
131072 KB |
Output is correct |
63 |
Correct |
608 ms |
131072 KB |
Output is correct |
64 |
Correct |
446 ms |
131072 KB |
Output is correct |
65 |
Correct |
437 ms |
131072 KB |
Output is correct |
66 |
Correct |
432 ms |
131072 KB |
Output is correct |
67 |
Correct |
443 ms |
131072 KB |
Output is correct |
68 |
Correct |
454 ms |
131072 KB |
Output is correct |
69 |
Correct |
428 ms |
131072 KB |
Output is correct |
70 |
Correct |
294 ms |
131072 KB |
Output is correct |
71 |
Correct |
455 ms |
131072 KB |
Output is correct |
72 |
Correct |
507 ms |
131072 KB |
Output is correct |
73 |
Correct |
537 ms |
131072 KB |
Output is correct |
74 |
Correct |
484 ms |
131072 KB |
Output is correct |
75 |
Correct |
483 ms |
131072 KB |
Output is correct |
76 |
Correct |
500 ms |
131072 KB |
Output is correct |
77 |
Correct |
503 ms |
131072 KB |
Output is correct |
78 |
Correct |
500 ms |
131072 KB |
Output is correct |
79 |
Correct |
427 ms |
131072 KB |
Output is correct |
80 |
Correct |
416 ms |
131072 KB |
Output is correct |
81 |
Correct |
417 ms |
131072 KB |
Output is correct |
82 |
Correct |
504 ms |
131072 KB |
Output is correct |
83 |
Correct |
530 ms |
131072 KB |
Output is correct |
84 |
Correct |
411 ms |
131072 KB |
Output is correct |
85 |
Correct |
478 ms |
131072 KB |
Output is correct |
86 |
Correct |
460 ms |
131072 KB |
Output is correct |
87 |
Correct |
460 ms |
131072 KB |
Output is correct |
88 |
Correct |
506 ms |
131072 KB |
Output is correct |
89 |
Correct |
456 ms |
131072 KB |
Output is correct |
90 |
Correct |
293 ms |
131072 KB |
Output is correct |
91 |
Correct |
451 ms |
131072 KB |
Output is correct |
92 |
Correct |
454 ms |
131072 KB |
Output is correct |
93 |
Correct |
452 ms |
131072 KB |
Output is correct |
94 |
Correct |
474 ms |
131072 KB |
Output is correct |
95 |
Correct |
497 ms |
131072 KB |
Output is correct |
96 |
Correct |
495 ms |
131072 KB |
Output is correct |
97 |
Correct |
487 ms |
131072 KB |
Output is correct |
98 |
Correct |
488 ms |
131072 KB |
Output is correct |
99 |
Correct |
469 ms |
131072 KB |
Output is correct |
100 |
Correct |
453 ms |
131072 KB |
Output is correct |