# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
332254 |
2020-12-01T19:27:19 Z |
vitkishloh228 |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
48464 KB |
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int solve1(int n, int m, vector<string> s) {
vector<vector<int>> pr(n + 1, vector<int>(m + 1));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
int val = s[i][j] - '0';
pr[i + 1][j + 1] = val + pr[i + 1][j] + pr[i][j + 1] - pr[i][j];
}
}
int maxlen = n;
for (int j = 0; j < m; ++j) {
int L0 = 0;
for (int i = 0; i < n; ++i) {
if (s[i][j] == '1') {
L0++;
}
else {
if (L0) {
maxlen = min(maxlen, L0);
}
L0 = 0;
}
}
if (L0) {
maxlen = min(maxlen, L0);
}
}
int tl = 0, tr = m + 100;
while (tl < tr - 1) {
int tm = (tl + tr) >> 1;
//tm = 2;
bool ok = true;
vector<int> freeze(n);
for (int j = 0; j < m; ++j) {
if (!ok) break;
for (int i = 0; i < n; ++i) {
if (s[i][j] == '1') {
if (i + maxlen <= n && j + tm <= m) {
int S = pr[i + maxlen][j + tm] + pr[i][j] - pr[i + maxlen][j] - pr[i][j + tm];
if (S != (maxlen * tm) && !freeze[i]) {
// cout << i << ' ' << j << ' '<<tm << endl;
ok = false;
break;
}
if (S == (maxlen * tm)) {
for (int k = i; k < i + maxlen; ++k) {
freeze[k] = tm;
}
//i += maxlen - 1;
//continue;
}
}
else if (!freeze[i]) {
// cout << i << ' ' << j << ' ' << tm << endl;
ok = 0;
break;
}
freeze[i]--;
}
}
}
if (ok) {
//cout << "YES";
tl = tm;
}
else tr = tm;
}
return (maxlen * tl);
}
int main() {
int n, m;
cin >> n >> m;
vector<string> s(n);
for (int i = 0; i < n; ++i) cin >> s[i];
int q1 = solve1(n, m, s);
vector<string> r(m, string(n, '0'));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
r[j][i] = s[i][j];
}
}
int q2 = solve1(m, n, r);
cout << max(q1, q2);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
640 KB |
Output is correct |
4 |
Correct |
2 ms |
620 KB |
Output is correct |
5 |
Correct |
1 ms |
620 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
364 KB |
Output isn't correct |
26 |
Correct |
2 ms |
364 KB |
Output is correct |
27 |
Correct |
6 ms |
1004 KB |
Output is correct |
28 |
Incorrect |
6 ms |
1340 KB |
Output isn't correct |
29 |
Incorrect |
54 ms |
1396 KB |
Output isn't correct |
30 |
Incorrect |
11 ms |
1856 KB |
Output isn't correct |
31 |
Incorrect |
10 ms |
1532 KB |
Output isn't correct |
32 |
Incorrect |
9 ms |
1624 KB |
Output isn't correct |
33 |
Incorrect |
15 ms |
2032 KB |
Output isn't correct |
34 |
Incorrect |
5 ms |
1060 KB |
Output isn't correct |
35 |
Incorrect |
13 ms |
2032 KB |
Output isn't correct |
36 |
Correct |
72 ms |
2032 KB |
Output is correct |
37 |
Correct |
1 ms |
364 KB |
Output is correct |
38 |
Correct |
940 ms |
48372 KB |
Output is correct |
39 |
Correct |
1 ms |
364 KB |
Output is correct |
40 |
Correct |
545 ms |
6528 KB |
Output is correct |
41 |
Correct |
1 ms |
364 KB |
Output is correct |
42 |
Incorrect |
2 ms |
364 KB |
Output isn't correct |
43 |
Execution timed out |
1087 ms |
42092 KB |
Time limit exceeded |
44 |
Incorrect |
86 ms |
2032 KB |
Output isn't correct |
45 |
Execution timed out |
1094 ms |
41964 KB |
Time limit exceeded |
46 |
Correct |
874 ms |
48280 KB |
Output is correct |
47 |
Execution timed out |
1064 ms |
41964 KB |
Time limit exceeded |
48 |
Execution timed out |
1074 ms |
41964 KB |
Time limit exceeded |
49 |
Execution timed out |
1071 ms |
48412 KB |
Time limit exceeded |
50 |
Execution timed out |
1045 ms |
48340 KB |
Time limit exceeded |
51 |
Execution timed out |
1091 ms |
41964 KB |
Time limit exceeded |
52 |
Execution timed out |
1089 ms |
41964 KB |
Time limit exceeded |
53 |
Execution timed out |
1069 ms |
48284 KB |
Time limit exceeded |
54 |
Execution timed out |
1094 ms |
48284 KB |
Time limit exceeded |
55 |
Execution timed out |
1097 ms |
48284 KB |
Time limit exceeded |
56 |
Correct |
951 ms |
48284 KB |
Output is correct |
57 |
Execution timed out |
1100 ms |
41964 KB |
Time limit exceeded |
58 |
Execution timed out |
1038 ms |
41932 KB |
Time limit exceeded |
59 |
Execution timed out |
1057 ms |
41964 KB |
Time limit exceeded |
60 |
Execution timed out |
1095 ms |
41964 KB |
Time limit exceeded |
61 |
Execution timed out |
1072 ms |
41964 KB |
Time limit exceeded |
62 |
Execution timed out |
1095 ms |
41964 KB |
Time limit exceeded |
63 |
Execution timed out |
1028 ms |
42100 KB |
Time limit exceeded |
64 |
Execution timed out |
1067 ms |
48412 KB |
Time limit exceeded |
65 |
Execution timed out |
1095 ms |
41964 KB |
Time limit exceeded |
66 |
Execution timed out |
1053 ms |
48152 KB |
Time limit exceeded |
67 |
Execution timed out |
1097 ms |
41964 KB |
Time limit exceeded |
68 |
Execution timed out |
1046 ms |
42092 KB |
Time limit exceeded |
69 |
Execution timed out |
1065 ms |
42060 KB |
Time limit exceeded |
70 |
Incorrect |
699 ms |
33212 KB |
Output isn't correct |
71 |
Incorrect |
992 ms |
48280 KB |
Output isn't correct |
72 |
Execution timed out |
1101 ms |
48152 KB |
Time limit exceeded |
73 |
Execution timed out |
1099 ms |
48152 KB |
Time limit exceeded |
74 |
Execution timed out |
1099 ms |
48232 KB |
Time limit exceeded |
75 |
Execution timed out |
1102 ms |
48152 KB |
Time limit exceeded |
76 |
Execution timed out |
1087 ms |
48232 KB |
Time limit exceeded |
77 |
Execution timed out |
1090 ms |
48328 KB |
Time limit exceeded |
78 |
Execution timed out |
1090 ms |
48464 KB |
Time limit exceeded |
79 |
Incorrect |
376 ms |
48280 KB |
Output isn't correct |
80 |
Incorrect |
395 ms |
48152 KB |
Output isn't correct |
81 |
Incorrect |
451 ms |
48280 KB |
Output isn't correct |
82 |
Execution timed out |
1092 ms |
48284 KB |
Time limit exceeded |
83 |
Execution timed out |
1087 ms |
48284 KB |
Time limit exceeded |
84 |
Incorrect |
372 ms |
48280 KB |
Output isn't correct |
85 |
Execution timed out |
1089 ms |
48288 KB |
Time limit exceeded |
86 |
Execution timed out |
1086 ms |
48284 KB |
Time limit exceeded |
87 |
Execution timed out |
1089 ms |
48408 KB |
Time limit exceeded |
88 |
Execution timed out |
1081 ms |
48288 KB |
Time limit exceeded |
89 |
Execution timed out |
1089 ms |
48284 KB |
Time limit exceeded |
90 |
Incorrect |
533 ms |
33084 KB |
Output isn't correct |
91 |
Execution timed out |
1092 ms |
48284 KB |
Time limit exceeded |
92 |
Execution timed out |
1083 ms |
41964 KB |
Time limit exceeded |
93 |
Execution timed out |
1087 ms |
48292 KB |
Time limit exceeded |
94 |
Execution timed out |
1071 ms |
42048 KB |
Time limit exceeded |
95 |
Execution timed out |
1101 ms |
48152 KB |
Time limit exceeded |
96 |
Execution timed out |
1078 ms |
48264 KB |
Time limit exceeded |
97 |
Execution timed out |
1062 ms |
48132 KB |
Time limit exceeded |
98 |
Execution timed out |
1084 ms |
47968 KB |
Time limit exceeded |
99 |
Execution timed out |
1089 ms |
47768 KB |
Time limit exceeded |
100 |
Execution timed out |
1089 ms |
47864 KB |
Time limit exceeded |