# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
171599 |
2019-12-29T10:40:20 Z |
mcdx9524 |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
15736 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2500 + 7;
char a[N][N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
if (n == 1 || m == 1) {
vector <int> aa;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
char x;
cin >> x;
aa.push_back(x - '0');
}
}
int cnt = 1;
int res = 1e9;
for (int i = 1; i < max(n, m); i++) {
if (aa[i] != aa[i - 1]) {
if (aa[i - 1] == 1) {
res = min(res, cnt);
}
cnt = 0;
}
cnt++;
}
if (aa[max(n, m) - 1] == 1) {
res = min(res, cnt);
}
cout << res << '\n';
return 0;
}
if (max(n, m) > 100) {
//assert(0);
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
int ans = 0;
for (int x = 1; x <= n; x++) {
int bl = 1, br = m;
while (bl <= br) {
int y = (bl + br) / 2;
char b[n + 7][m + 7];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
b[i][j] = a[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (i + x - 1 > n || j + y - 1 > m) {
continue;
}
bool bad = false;
for (int r = i; r <= i + x - 1; r++) {
for (int c = j; c <= j + y - 1; c++) {
if (b[r][c] == '0') {
bad = true;
}
if (bad) break;
}
if (bad) break;
}
if (bad) continue;
for (int r = i; r <= i + x - 1; r++) {
for (int c = j; c <= j + y - 1; c++) {
b[r][c] = '2';
}
}
}
}
bool good = true;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == '0') {
continue;
}
if (a[i][j] == '1' && b[i][j] == '2') {
continue;
}
good = false;
if (!good) break;
}
if (!good) break;
}
if (good) {
bl = y + 1;
ans = max(ans, x * y);
} else {
br = y - 1;
}
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
476 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
1 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
17 |
Correct |
11 ms |
504 KB |
Output is correct |
18 |
Correct |
7 ms |
504 KB |
Output is correct |
19 |
Correct |
26 ms |
632 KB |
Output is correct |
20 |
Correct |
26 ms |
632 KB |
Output is correct |
21 |
Correct |
6 ms |
504 KB |
Output is correct |
22 |
Correct |
12 ms |
632 KB |
Output is correct |
23 |
Correct |
74 ms |
632 KB |
Output is correct |
24 |
Correct |
22 ms |
632 KB |
Output is correct |
25 |
Correct |
113 ms |
632 KB |
Output is correct |
26 |
Correct |
721 ms |
652 KB |
Output is correct |
27 |
Execution timed out |
1078 ms |
1272 KB |
Time limit exceeded |
28 |
Correct |
618 ms |
1320 KB |
Output is correct |
29 |
Execution timed out |
1068 ms |
1528 KB |
Time limit exceeded |
30 |
Execution timed out |
1075 ms |
1784 KB |
Time limit exceeded |
31 |
Execution timed out |
1067 ms |
1400 KB |
Time limit exceeded |
32 |
Execution timed out |
1079 ms |
1656 KB |
Time limit exceeded |
33 |
Execution timed out |
1072 ms |
1912 KB |
Time limit exceeded |
34 |
Correct |
534 ms |
1432 KB |
Output is correct |
35 |
Execution timed out |
1079 ms |
1912 KB |
Time limit exceeded |
36 |
Execution timed out |
1081 ms |
1912 KB |
Time limit exceeded |
37 |
Correct |
1 ms |
376 KB |
Output is correct |
38 |
Execution timed out |
1077 ms |
15448 KB |
Time limit exceeded |
39 |
Correct |
2 ms |
376 KB |
Output is correct |
40 |
Execution timed out |
1086 ms |
3960 KB |
Time limit exceeded |
41 |
Correct |
2 ms |
376 KB |
Output is correct |
42 |
Correct |
503 ms |
684 KB |
Output is correct |
43 |
Execution timed out |
1080 ms |
15404 KB |
Time limit exceeded |
44 |
Execution timed out |
1070 ms |
1912 KB |
Time limit exceeded |
45 |
Execution timed out |
1079 ms |
15480 KB |
Time limit exceeded |
46 |
Execution timed out |
1071 ms |
15472 KB |
Time limit exceeded |
47 |
Execution timed out |
1071 ms |
15480 KB |
Time limit exceeded |
48 |
Execution timed out |
1076 ms |
15568 KB |
Time limit exceeded |
49 |
Execution timed out |
1079 ms |
15480 KB |
Time limit exceeded |
50 |
Execution timed out |
1080 ms |
15480 KB |
Time limit exceeded |
51 |
Execution timed out |
1076 ms |
15356 KB |
Time limit exceeded |
52 |
Execution timed out |
1081 ms |
15480 KB |
Time limit exceeded |
53 |
Execution timed out |
1075 ms |
15456 KB |
Time limit exceeded |
54 |
Execution timed out |
1081 ms |
15352 KB |
Time limit exceeded |
55 |
Execution timed out |
1064 ms |
15436 KB |
Time limit exceeded |
56 |
Execution timed out |
1076 ms |
15480 KB |
Time limit exceeded |
57 |
Execution timed out |
1069 ms |
15480 KB |
Time limit exceeded |
58 |
Execution timed out |
1081 ms |
15352 KB |
Time limit exceeded |
59 |
Execution timed out |
1078 ms |
15480 KB |
Time limit exceeded |
60 |
Execution timed out |
1061 ms |
15736 KB |
Time limit exceeded |
61 |
Execution timed out |
1065 ms |
15736 KB |
Time limit exceeded |
62 |
Execution timed out |
1057 ms |
15736 KB |
Time limit exceeded |
63 |
Execution timed out |
1069 ms |
15664 KB |
Time limit exceeded |
64 |
Execution timed out |
1074 ms |
15656 KB |
Time limit exceeded |
65 |
Execution timed out |
1074 ms |
15736 KB |
Time limit exceeded |
66 |
Execution timed out |
1085 ms |
15708 KB |
Time limit exceeded |
67 |
Execution timed out |
1082 ms |
15660 KB |
Time limit exceeded |
68 |
Execution timed out |
1071 ms |
15736 KB |
Time limit exceeded |
69 |
Execution timed out |
1076 ms |
15708 KB |
Time limit exceeded |
70 |
Execution timed out |
1077 ms |
12284 KB |
Time limit exceeded |
71 |
Execution timed out |
1071 ms |
15608 KB |
Time limit exceeded |
72 |
Execution timed out |
1081 ms |
15736 KB |
Time limit exceeded |
73 |
Execution timed out |
1084 ms |
15608 KB |
Time limit exceeded |
74 |
Execution timed out |
1082 ms |
15736 KB |
Time limit exceeded |
75 |
Execution timed out |
1069 ms |
15480 KB |
Time limit exceeded |
76 |
Execution timed out |
1073 ms |
15352 KB |
Time limit exceeded |
77 |
Execution timed out |
1077 ms |
15224 KB |
Time limit exceeded |
78 |
Execution timed out |
1082 ms |
15324 KB |
Time limit exceeded |
79 |
Execution timed out |
1080 ms |
15224 KB |
Time limit exceeded |
80 |
Execution timed out |
1080 ms |
15352 KB |
Time limit exceeded |
81 |
Execution timed out |
1080 ms |
15324 KB |
Time limit exceeded |
82 |
Execution timed out |
1085 ms |
15224 KB |
Time limit exceeded |
83 |
Execution timed out |
1080 ms |
15452 KB |
Time limit exceeded |
84 |
Execution timed out |
1074 ms |
15368 KB |
Time limit exceeded |
85 |
Execution timed out |
1080 ms |
15348 KB |
Time limit exceeded |
86 |
Execution timed out |
1076 ms |
15052 KB |
Time limit exceeded |
87 |
Execution timed out |
1079 ms |
15096 KB |
Time limit exceeded |
88 |
Execution timed out |
1079 ms |
15096 KB |
Time limit exceeded |
89 |
Execution timed out |
1074 ms |
14968 KB |
Time limit exceeded |
90 |
Execution timed out |
1089 ms |
11256 KB |
Time limit exceeded |
91 |
Execution timed out |
1069 ms |
14712 KB |
Time limit exceeded |
92 |
Execution timed out |
1065 ms |
14600 KB |
Time limit exceeded |
93 |
Execution timed out |
1066 ms |
14712 KB |
Time limit exceeded |
94 |
Execution timed out |
1070 ms |
14772 KB |
Time limit exceeded |
95 |
Execution timed out |
1084 ms |
14712 KB |
Time limit exceeded |
96 |
Execution timed out |
1076 ms |
14712 KB |
Time limit exceeded |
97 |
Execution timed out |
1074 ms |
14456 KB |
Time limit exceeded |
98 |
Execution timed out |
1079 ms |
14200 KB |
Time limit exceeded |
99 |
Execution timed out |
1067 ms |
14328 KB |
Time limit exceeded |
100 |
Execution timed out |
1073 ms |
14292 KB |
Time limit exceeded |