# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
43150 |
2018-03-09T14:50:30 Z |
cheater2k |
Bomb (IZhO17_bomb) |
C++14 |
|
487 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 cur = ncol;
if (down[i][j] == 1) {
for (int k = i; k >= i - nrow + 1; --k) {
if (left[i][j] == 1) cur = min(cur, right[k][j]), c[i - k + 1] = min(c[i - k + 1], cur);
if (right[i][j] == 1) cur = min(cur, left[k][j]), c[i - k + 1] = min(c[i - k + 1], cur);
}
} else if (up[i][j] == 1) {
for (int k = i; k <= i + nrow - 1; ++k) {
if (left[i][j] == 1) cur = min(cur, right[k][j]), c[k - i + 1] = min(c[k - i + 1], cur);
if (right[i][j] == 1) cur = min(cur, left[k][j]), c[k - i + 1] = min(c[k - i + 1], cur);
}
}
}
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 |
868 KB |
Output is correct |
3 |
Correct |
37 ms |
46872 KB |
Output is correct |
4 |
Correct |
37 ms |
46872 KB |
Output is correct |
5 |
Correct |
1 ms |
46872 KB |
Output is correct |
6 |
Correct |
1 ms |
46872 KB |
Output is correct |
7 |
Correct |
1 ms |
46872 KB |
Output is correct |
8 |
Correct |
2 ms |
46872 KB |
Output is correct |
9 |
Correct |
2 ms |
46872 KB |
Output is correct |
10 |
Correct |
1 ms |
46872 KB |
Output is correct |
11 |
Correct |
2 ms |
46872 KB |
Output is correct |
12 |
Correct |
2 ms |
46872 KB |
Output is correct |
13 |
Correct |
2 ms |
46872 KB |
Output is correct |
14 |
Correct |
2 ms |
46872 KB |
Output is correct |
15 |
Correct |
2 ms |
46872 KB |
Output is correct |
16 |
Correct |
2 ms |
46872 KB |
Output is correct |
17 |
Correct |
2 ms |
46872 KB |
Output is correct |
18 |
Correct |
2 ms |
46872 KB |
Output is correct |
19 |
Correct |
3 ms |
46872 KB |
Output is correct |
20 |
Correct |
3 ms |
46872 KB |
Output is correct |
21 |
Correct |
2 ms |
46872 KB |
Output is correct |
22 |
Correct |
2 ms |
46872 KB |
Output is correct |
23 |
Correct |
3 ms |
46872 KB |
Output is correct |
24 |
Correct |
2 ms |
46872 KB |
Output is correct |
25 |
Correct |
3 ms |
46872 KB |
Output is correct |
26 |
Correct |
3 ms |
46872 KB |
Output is correct |
27 |
Correct |
8 ms |
46872 KB |
Output is correct |
28 |
Correct |
8 ms |
46872 KB |
Output is correct |
29 |
Correct |
12 ms |
46872 KB |
Output is correct |
30 |
Correct |
13 ms |
46872 KB |
Output is correct |
31 |
Correct |
10 ms |
46872 KB |
Output is correct |
32 |
Correct |
14 ms |
46872 KB |
Output is correct |
33 |
Correct |
14 ms |
46872 KB |
Output is correct |
34 |
Correct |
8 ms |
46872 KB |
Output is correct |
35 |
Correct |
14 ms |
46872 KB |
Output is correct |
36 |
Correct |
16 ms |
46872 KB |
Output is correct |
37 |
Correct |
2 ms |
46872 KB |
Output is correct |
38 |
Correct |
465 ms |
112500 KB |
Output is correct |
39 |
Correct |
2 ms |
112500 KB |
Output is correct |
40 |
Incorrect |
58 ms |
112500 KB |
Output isn't correct |
41 |
Correct |
2 ms |
112500 KB |
Output is correct |
42 |
Correct |
3 ms |
112500 KB |
Output is correct |
43 |
Correct |
469 ms |
119628 KB |
Output is correct |
44 |
Correct |
17 ms |
119628 KB |
Output is correct |
45 |
Correct |
474 ms |
126008 KB |
Output is correct |
46 |
Correct |
456 ms |
131072 KB |
Output is correct |
47 |
Correct |
452 ms |
131072 KB |
Output is correct |
48 |
Correct |
458 ms |
131072 KB |
Output is correct |
49 |
Correct |
449 ms |
131072 KB |
Output is correct |
50 |
Correct |
438 ms |
131072 KB |
Output is correct |
51 |
Correct |
454 ms |
131072 KB |
Output is correct |
52 |
Correct |
448 ms |
131072 KB |
Output is correct |
53 |
Correct |
448 ms |
131072 KB |
Output is correct |
54 |
Correct |
423 ms |
131072 KB |
Output is correct |
55 |
Correct |
427 ms |
131072 KB |
Output is correct |
56 |
Correct |
465 ms |
131072 KB |
Output is correct |
57 |
Correct |
452 ms |
131072 KB |
Output is correct |
58 |
Correct |
441 ms |
131072 KB |
Output is correct |
59 |
Correct |
425 ms |
131072 KB |
Output is correct |
60 |
Correct |
445 ms |
131072 KB |
Output is correct |
61 |
Correct |
462 ms |
131072 KB |
Output is correct |
62 |
Correct |
487 ms |
131072 KB |
Output is correct |
63 |
Correct |
456 ms |
131072 KB |
Output is correct |
64 |
Correct |
435 ms |
131072 KB |
Output is correct |
65 |
Correct |
434 ms |
131072 KB |
Output is correct |
66 |
Correct |
450 ms |
131072 KB |
Output is correct |
67 |
Correct |
454 ms |
131072 KB |
Output is correct |
68 |
Correct |
458 ms |
131072 KB |
Output is correct |
69 |
Correct |
424 ms |
131072 KB |
Output is correct |
70 |
Correct |
273 ms |
131072 KB |
Output is correct |
71 |
Correct |
435 ms |
131072 KB |
Output is correct |
72 |
Correct |
443 ms |
131072 KB |
Output is correct |
73 |
Correct |
421 ms |
131072 KB |
Output is correct |
74 |
Correct |
424 ms |
131072 KB |
Output is correct |
75 |
Correct |
440 ms |
131072 KB |
Output is correct |
76 |
Correct |
438 ms |
131072 KB |
Output is correct |
77 |
Correct |
450 ms |
131072 KB |
Output is correct |
78 |
Correct |
438 ms |
131072 KB |
Output is correct |
79 |
Correct |
420 ms |
131072 KB |
Output is correct |
80 |
Correct |
423 ms |
131072 KB |
Output is correct |
81 |
Correct |
429 ms |
131072 KB |
Output is correct |
82 |
Correct |
443 ms |
131072 KB |
Output is correct |
83 |
Correct |
438 ms |
131072 KB |
Output is correct |
84 |
Correct |
439 ms |
131072 KB |
Output is correct |
85 |
Correct |
430 ms |
131072 KB |
Output is correct |
86 |
Correct |
447 ms |
131072 KB |
Output is correct |
87 |
Correct |
430 ms |
131072 KB |
Output is correct |
88 |
Correct |
428 ms |
131072 KB |
Output is correct |
89 |
Correct |
424 ms |
131072 KB |
Output is correct |
90 |
Correct |
272 ms |
131072 KB |
Output is correct |
91 |
Correct |
428 ms |
131072 KB |
Output is correct |
92 |
Correct |
428 ms |
131072 KB |
Output is correct |
93 |
Correct |
447 ms |
131072 KB |
Output is correct |
94 |
Correct |
432 ms |
131072 KB |
Output is correct |
95 |
Correct |
433 ms |
131072 KB |
Output is correct |
96 |
Correct |
426 ms |
131072 KB |
Output is correct |
97 |
Correct |
449 ms |
131072 KB |
Output is correct |
98 |
Correct |
429 ms |
131072 KB |
Output is correct |
99 |
Correct |
441 ms |
131072 KB |
Output is correct |
100 |
Correct |
453 ms |
131072 KB |
Output is correct |