# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100546 | 2019-03-12T07:34:48 Z | alexpetrescu | Bomb (IZhO17_bomb) | C++14 | 566 ms | 56824 KB |
#include <cstdio> #include <algorithm> //FILE *fin = fopen("a.in", "r"), *fout = fopen("a.out", "w"); #define fin stdin #define fout stdout #define MAXN 2500 int left[MAXN + 2][MAXN + 2], right[MAXN + 2][MAXN + 2]; int d[MAXN + 2]; char m[MAXN + 2][MAXN + 10]; int nrlin, nrcol; inline void solve() { for (int i = 1; i <= nrlin; i++) { left[i][0] = 0; for (int j = 1; j <= nrcol; j++) if (m[i][j] == '1') left[i][j] = left[i][j - 1]; else left[i][j] = j; right[i][nrcol + 1] = nrcol + 1; for (int j = nrcol; j > 0; j--) if (m[i][j] == '1') right[i][j] = right[i][j + 1]; else right[i][j] = j; for (int j = 1; j <= nrcol; j++) if (m[i][j] == '1') d[1] = std::min(d[1], right[i][j] - left[i][j] - 1); } for (int j = 1; j <= nrcol; j++) { int val = nrcol, cat = 0; for (int i = 1; i <= nrlin; i++) { if (m[i][j] == '1') { val = std::min(val, right[i][j] - left[i][j] - 1); cat++; d[cat] = std::min(d[cat], val); } else { if (cat) d[cat + 1] = 0; val = nrcol; cat = 0; } } if (cat) d[cat + 1] = 0; } } int main() { fscanf(fin, "%d%d ", &nrlin, &nrcol); for (int i = 1; i <= nrlin; i++) fgets(m[i] + 1, MAXN + 5, fin), d[i] = nrcol; solve(); for (int i = 1; i <= nrlin / 2; i++) for (int j = 1; j <= nrcol; j++) std::swap(m[i][j], m[nrlin - i + 1][j]); solve(); for (int i = 2; i <= nrlin; i++) d[i] = std::min(d[i], d[i - 1]); int ans = d[1]; for (int i = 2; i <= nrlin; i++) ans = std::max(ans, i * d[i]); fprintf(fout, "%d\n", ans); fclose(fin); fclose(fout); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 512 KB | Output is correct |
3 | Correct | 21 ms | 26496 KB | Output is correct |
4 | Correct | 27 ms | 26624 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Incorrect | 2 ms | 512 KB | Output isn't correct |
9 | Incorrect | 2 ms | 512 KB | Output isn't correct |
10 | Incorrect | 2 ms | 512 KB | Output isn't correct |
11 | Incorrect | 2 ms | 512 KB | Output isn't correct |
12 | Incorrect | 2 ms | 512 KB | Output isn't correct |
13 | Correct | 3 ms | 512 KB | Output is correct |
14 | Correct | 3 ms | 512 KB | Output is correct |
15 | Incorrect | 2 ms | 512 KB | Output isn't correct |
16 | Correct | 2 ms | 512 KB | Output is correct |
17 | Correct | 3 ms | 1024 KB | Output is correct |
18 | Incorrect | 3 ms | 1152 KB | Output isn't correct |
19 | Incorrect | 3 ms | 1408 KB | Output isn't correct |
20 | Incorrect | 3 ms | 1280 KB | Output isn't correct |
21 | Incorrect | 3 ms | 896 KB | Output isn't correct |
22 | Incorrect | 3 ms | 1152 KB | Output isn't correct |
23 | Incorrect | 3 ms | 1408 KB | Output isn't correct |
24 | Incorrect | 3 ms | 1152 KB | Output isn't correct |
25 | Incorrect | 3 ms | 1408 KB | Output isn't correct |
26 | Correct | 3 ms | 1408 KB | Output is correct |
27 | Correct | 8 ms | 4096 KB | Output is correct |
28 | Incorrect | 7 ms | 4352 KB | Output isn't correct |
29 | Incorrect | 9 ms | 5504 KB | Output isn't correct |
30 | Incorrect | 12 ms | 6528 KB | Output isn't correct |
31 | Incorrect | 9 ms | 5120 KB | Output isn't correct |
32 | Incorrect | 4 ms | 6016 KB | Output isn't correct |
33 | Incorrect | 10 ms | 6784 KB | Output isn't correct |
34 | Incorrect | 7 ms | 4736 KB | Output isn't correct |
35 | Incorrect | 10 ms | 6784 KB | Output isn't correct |
36 | Correct | 15 ms | 6916 KB | Output is correct |
37 | Incorrect | 2 ms | 512 KB | Output isn't correct |
38 | Correct | 566 ms | 56824 KB | Output is correct |
39 | Incorrect | 2 ms | 512 KB | Output isn't correct |
40 | Incorrect | 53 ms | 16256 KB | Output isn't correct |
41 | Incorrect | 2 ms | 512 KB | Output isn't correct |
42 | Incorrect | 4 ms | 1408 KB | Output isn't correct |
43 | Correct | 421 ms | 56748 KB | Output is correct |
44 | Incorrect | 10 ms | 6784 KB | Output isn't correct |
45 | Incorrect | 407 ms | 56696 KB | Output isn't correct |
46 | Correct | 352 ms | 56744 KB | Output is correct |
47 | Incorrect | 389 ms | 56696 KB | Output isn't correct |
48 | Incorrect | 372 ms | 56824 KB | Output isn't correct |
49 | Correct | 558 ms | 56688 KB | Output is correct |
50 | Incorrect | 407 ms | 56824 KB | Output isn't correct |
51 | Incorrect | 382 ms | 56824 KB | Output isn't correct |
52 | Incorrect | 368 ms | 56776 KB | Output isn't correct |
53 | Incorrect | 363 ms | 56716 KB | Output isn't correct |
54 | Incorrect | 241 ms | 56696 KB | Output isn't correct |
55 | Incorrect | 246 ms | 56824 KB | Output isn't correct |
56 | Correct | 523 ms | 56696 KB | Output is correct |
57 | Incorrect | 229 ms | 56760 KB | Output isn't correct |
58 | Incorrect | 231 ms | 56568 KB | Output isn't correct |
59 | Incorrect | 283 ms | 56568 KB | Output isn't correct |
60 | Correct | 370 ms | 56568 KB | Output is correct |
61 | Correct | 559 ms | 56568 KB | Output is correct |
62 | Correct | 542 ms | 56668 KB | Output is correct |
63 | Correct | 548 ms | 56524 KB | Output is correct |
64 | Correct | 252 ms | 56440 KB | Output is correct |
65 | Incorrect | 376 ms | 56676 KB | Output isn't correct |
66 | Incorrect | 352 ms | 56568 KB | Output isn't correct |
67 | Incorrect | 405 ms | 56752 KB | Output isn't correct |
68 | Incorrect | 396 ms | 56696 KB | Output isn't correct |
69 | Incorrect | 261 ms | 56696 KB | Output isn't correct |
70 | Incorrect | 139 ms | 45560 KB | Output isn't correct |
71 | Incorrect | 216 ms | 56568 KB | Output isn't correct |
72 | Incorrect | 226 ms | 56700 KB | Output isn't correct |
73 | Incorrect | 273 ms | 56640 KB | Output isn't correct |
74 | Incorrect | 244 ms | 56708 KB | Output isn't correct |
75 | Incorrect | 252 ms | 56552 KB | Output isn't correct |
76 | Incorrect | 272 ms | 56436 KB | Output isn't correct |
77 | Incorrect | 269 ms | 56568 KB | Output isn't correct |
78 | Incorrect | 319 ms | 56664 KB | Output isn't correct |
79 | Incorrect | 145 ms | 56472 KB | Output isn't correct |
80 | Incorrect | 140 ms | 56296 KB | Output isn't correct |
81 | Incorrect | 152 ms | 56312 KB | Output isn't correct |
82 | Incorrect | 277 ms | 56340 KB | Output isn't correct |
83 | Incorrect | 267 ms | 56184 KB | Output isn't correct |
84 | Incorrect | 129 ms | 56156 KB | Output isn't correct |
85 | Incorrect | 281 ms | 56184 KB | Output isn't correct |
86 | Incorrect | 507 ms | 56216 KB | Output isn't correct |
87 | Incorrect | 243 ms | 56184 KB | Output isn't correct |
88 | Incorrect | 273 ms | 56144 KB | Output isn't correct |
89 | Incorrect | 333 ms | 56184 KB | Output isn't correct |
90 | Incorrect | 131 ms | 45068 KB | Output isn't correct |
91 | Incorrect | 331 ms | 55928 KB | Output isn't correct |
92 | Incorrect | 346 ms | 56056 KB | Output isn't correct |
93 | Incorrect | 539 ms | 56032 KB | Output isn't correct |
94 | Incorrect | 324 ms | 56028 KB | Output isn't correct |
95 | Incorrect | 252 ms | 56056 KB | Output isn't correct |
96 | Incorrect | 242 ms | 56056 KB | Output isn't correct |
97 | Incorrect | 522 ms | 55884 KB | Output isn't correct |
98 | Incorrect | 292 ms | 55800 KB | Output isn't correct |
99 | Incorrect | 323 ms | 55896 KB | Output isn't correct |
100 | Incorrect | 454 ms | 55804 KB | Output isn't correct |