# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
43148 |
2018-03-09T14:40:30 Z |
cheater2k |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 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;
const int dx[] = {0, 0, -1, +1};
const int dy[] = {-1, +1, 0, 0};
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];
bool vis[N][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) {
int c = ncol;
for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) {
if (a[i][j] != '1') continue;
if (down[i][j] == 1) {
for (int k = i; k >= i - r + 1; --k) {
if (left[i][j] == 1) c = min(c, right[k][j]);
if (right[i][j] == 1) c = min(c, left[k][j]);
}
} else if (up[i][j] == 1) {
for (int k = i; k <= i + r - 1; ++k) {
if (left[i][j] == 1) c = min(c, right[k][j]);
if (right[i][j] == 1) c = min(c, left[k][j]);
}
}
}
res = max(res, r * c);
}
cout << res << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
740 KB |
Output is correct |
3 |
Correct |
42 ms |
46768 KB |
Output is correct |
4 |
Correct |
45 ms |
46848 KB |
Output is correct |
5 |
Correct |
2 ms |
46848 KB |
Output is correct |
6 |
Correct |
2 ms |
46848 KB |
Output is correct |
7 |
Correct |
2 ms |
46848 KB |
Output is correct |
8 |
Correct |
2 ms |
46848 KB |
Output is correct |
9 |
Correct |
2 ms |
46848 KB |
Output is correct |
10 |
Correct |
2 ms |
46848 KB |
Output is correct |
11 |
Correct |
2 ms |
46848 KB |
Output is correct |
12 |
Correct |
2 ms |
46848 KB |
Output is correct |
13 |
Correct |
2 ms |
46848 KB |
Output is correct |
14 |
Correct |
2 ms |
46848 KB |
Output is correct |
15 |
Correct |
2 ms |
46848 KB |
Output is correct |
16 |
Correct |
2 ms |
46848 KB |
Output is correct |
17 |
Correct |
2 ms |
46848 KB |
Output is correct |
18 |
Correct |
3 ms |
46848 KB |
Output is correct |
19 |
Correct |
3 ms |
46848 KB |
Output is correct |
20 |
Correct |
3 ms |
46848 KB |
Output is correct |
21 |
Correct |
3 ms |
46848 KB |
Output is correct |
22 |
Correct |
3 ms |
46848 KB |
Output is correct |
23 |
Correct |
3 ms |
46848 KB |
Output is correct |
24 |
Correct |
3 ms |
46848 KB |
Output is correct |
25 |
Correct |
4 ms |
46848 KB |
Output is correct |
26 |
Correct |
4 ms |
46848 KB |
Output is correct |
27 |
Correct |
11 ms |
46848 KB |
Output is correct |
28 |
Correct |
10 ms |
46848 KB |
Output is correct |
29 |
Correct |
37 ms |
46848 KB |
Output is correct |
30 |
Correct |
46 ms |
46848 KB |
Output is correct |
31 |
Correct |
24 ms |
46848 KB |
Output is correct |
32 |
Correct |
32 ms |
46848 KB |
Output is correct |
33 |
Correct |
56 ms |
46848 KB |
Output is correct |
34 |
Correct |
9 ms |
46848 KB |
Output is correct |
35 |
Correct |
17 ms |
46848 KB |
Output is correct |
36 |
Correct |
38 ms |
46848 KB |
Output is correct |
37 |
Correct |
2 ms |
46848 KB |
Output is correct |
38 |
Execution timed out |
1065 ms |
112680 KB |
Time limit exceeded |
39 |
Correct |
2 ms |
112680 KB |
Output is correct |
40 |
Incorrect |
710 ms |
112680 KB |
Output isn't correct |
41 |
Correct |
2 ms |
112680 KB |
Output is correct |
42 |
Correct |
5 ms |
112680 KB |
Output is correct |
43 |
Execution timed out |
1071 ms |
119528 KB |
Time limit exceeded |
44 |
Correct |
116 ms |
119528 KB |
Output is correct |
45 |
Execution timed out |
1073 ms |
125892 KB |
Time limit exceeded |
46 |
Correct |
931 ms |
131072 KB |
Output is correct |
47 |
Execution timed out |
1082 ms |
131072 KB |
Time limit exceeded |
48 |
Correct |
871 ms |
131072 KB |
Output is correct |
49 |
Correct |
522 ms |
131072 KB |
Output is correct |
50 |
Correct |
896 ms |
131072 KB |
Output is correct |
51 |
Correct |
878 ms |
131072 KB |
Output is correct |
52 |
Correct |
948 ms |
131072 KB |
Output is correct |
53 |
Correct |
907 ms |
131072 KB |
Output is correct |
54 |
Correct |
874 ms |
131072 KB |
Output is correct |
55 |
Correct |
829 ms |
131072 KB |
Output is correct |
56 |
Execution timed out |
1079 ms |
131072 KB |
Time limit exceeded |
57 |
Correct |
731 ms |
131072 KB |
Output is correct |
58 |
Correct |
827 ms |
131072 KB |
Output is correct |
59 |
Correct |
791 ms |
131072 KB |
Output is correct |
60 |
Correct |
731 ms |
131072 KB |
Output is correct |
61 |
Correct |
679 ms |
131072 KB |
Output is correct |
62 |
Execution timed out |
1069 ms |
131072 KB |
Time limit exceeded |
63 |
Execution timed out |
1071 ms |
131072 KB |
Time limit exceeded |
64 |
Execution timed out |
1069 ms |
131072 KB |
Time limit exceeded |
65 |
Correct |
932 ms |
131072 KB |
Output is correct |
66 |
Correct |
530 ms |
131072 KB |
Output is correct |
67 |
Correct |
839 ms |
131072 KB |
Output is correct |
68 |
Correct |
917 ms |
131072 KB |
Output is correct |
69 |
Correct |
717 ms |
131072 KB |
Output is correct |
70 |
Execution timed out |
1063 ms |
131072 KB |
Time limit exceeded |
71 |
Execution timed out |
1071 ms |
131072 KB |
Time limit exceeded |
72 |
Execution timed out |
1070 ms |
131072 KB |
Time limit exceeded |
73 |
Execution timed out |
1077 ms |
131072 KB |
Time limit exceeded |
74 |
Execution timed out |
1065 ms |
131072 KB |
Time limit exceeded |
75 |
Execution timed out |
1060 ms |
131072 KB |
Time limit exceeded |
76 |
Execution timed out |
1067 ms |
131072 KB |
Time limit exceeded |
77 |
Execution timed out |
1088 ms |
131072 KB |
Time limit exceeded |
78 |
Execution timed out |
1075 ms |
131072 KB |
Time limit exceeded |
79 |
Execution timed out |
1079 ms |
131072 KB |
Time limit exceeded |
80 |
Execution timed out |
1073 ms |
131072 KB |
Time limit exceeded |
81 |
Execution timed out |
1075 ms |
131072 KB |
Time limit exceeded |
82 |
Execution timed out |
1078 ms |
131072 KB |
Time limit exceeded |
83 |
Execution timed out |
1076 ms |
131072 KB |
Time limit exceeded |
84 |
Correct |
503 ms |
131072 KB |
Output is correct |
85 |
Execution timed out |
1077 ms |
131072 KB |
Time limit exceeded |
86 |
Correct |
876 ms |
131072 KB |
Output is correct |
87 |
Execution timed out |
1069 ms |
131072 KB |
Time limit exceeded |
88 |
Execution timed out |
1078 ms |
131072 KB |
Time limit exceeded |
89 |
Execution timed out |
1063 ms |
131072 KB |
Time limit exceeded |
90 |
Execution timed out |
1086 ms |
131072 KB |
Time limit exceeded |
91 |
Execution timed out |
1078 ms |
131072 KB |
Time limit exceeded |
92 |
Execution timed out |
1078 ms |
131072 KB |
Time limit exceeded |
93 |
Execution timed out |
1081 ms |
131072 KB |
Time limit exceeded |
94 |
Execution timed out |
1070 ms |
131072 KB |
Time limit exceeded |
95 |
Execution timed out |
1084 ms |
131072 KB |
Time limit exceeded |
96 |
Execution timed out |
1064 ms |
131072 KB |
Time limit exceeded |
97 |
Correct |
833 ms |
131072 KB |
Output is correct |
98 |
Execution timed out |
1064 ms |
131072 KB |
Time limit exceeded |
99 |
Execution timed out |
1078 ms |
131072 KB |
Time limit exceeded |
100 |
Execution timed out |
1077 ms |
131072 KB |
Time limit exceeded |