# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100547 | 2019-03-12T07:37:18 Z | alexpetrescu | Bomb (IZhO17_bomb) | C++14 | 571 ms | 55928 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 st = 0, dr = nrcol + 1, cat = 0; for (int i = 1; i <= nrlin; i++) { if (m[i][j] == '1') { st = std::max(st, left[i][j]); dr = std::min(dr, right[i][j]); cat++; d[cat] = std::min(d[cat], dr - st + 1); } else { if (cat) d[cat + 1] = 0; st = 0, dr = nrcol + 1; 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 | 20 ms | 26496 KB | Output is correct |
4 | Correct | 22 ms | 26496 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 | 2 ms | 512 KB | Output is correct |
14 | Correct | 2 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 | 2 ms | 1024 KB | Output is correct |
18 | Incorrect | 2 ms | 1024 KB | Output isn't correct |
19 | Incorrect | 3 ms | 1408 KB | Output isn't correct |
20 | Incorrect | 2 ms | 1280 KB | Output isn't correct |
21 | Incorrect | 2 ms | 896 KB | Output isn't correct |
22 | Incorrect | 2 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 | 2 ms | 1408 KB | Output isn't correct |
26 | Correct | 2 ms | 1408 KB | Output is correct |
27 | Correct | 7 ms | 4096 KB | Output is correct |
28 | Incorrect | 7 ms | 4352 KB | Output isn't correct |
29 | Incorrect | 11 ms | 5504 KB | Output isn't correct |
30 | Incorrect | 9 ms | 6528 KB | Output isn't correct |
31 | Incorrect | 9 ms | 5120 KB | Output isn't correct |
32 | Incorrect | 9 ms | 6016 KB | Output isn't correct |
33 | Incorrect | 10 ms | 6784 KB | Output isn't correct |
34 | Incorrect | 6 ms | 4736 KB | Output isn't correct |
35 | Incorrect | 9 ms | 6784 KB | Output isn't correct |
36 | Correct | 14 ms | 6784 KB | Output is correct |
37 | Incorrect | 2 ms | 512 KB | Output isn't correct |
38 | Correct | 543 ms | 55800 KB | Output is correct |
39 | Incorrect | 2 ms | 512 KB | Output isn't correct |
40 | Correct | 60 ms | 15744 KB | Output is correct |
41 | Incorrect | 3 ms | 512 KB | Output isn't correct |
42 | Incorrect | 3 ms | 1536 KB | Output isn't correct |
43 | Correct | 434 ms | 55800 KB | Output is correct |
44 | Incorrect | 11 ms | 6784 KB | Output isn't correct |
45 | Incorrect | 429 ms | 55820 KB | Output isn't correct |
46 | Correct | 330 ms | 55672 KB | Output is correct |
47 | Incorrect | 438 ms | 55800 KB | Output isn't correct |
48 | Incorrect | 375 ms | 55672 KB | Output isn't correct |
49 | Correct | 571 ms | 55928 KB | Output is correct |
50 | Incorrect | 379 ms | 55800 KB | Output isn't correct |
51 | Incorrect | 410 ms | 55804 KB | Output isn't correct |
52 | Incorrect | 414 ms | 55836 KB | Output isn't correct |
53 | Incorrect | 373 ms | 55788 KB | Output isn't correct |
54 | Incorrect | 294 ms | 55712 KB | Output isn't correct |
55 | Incorrect | 260 ms | 55672 KB | Output isn't correct |
56 | Correct | 538 ms | 55784 KB | Output is correct |
57 | Incorrect | 247 ms | 55800 KB | Output isn't correct |
58 | Incorrect | 249 ms | 55800 KB | Output isn't correct |
59 | Incorrect | 236 ms | 55928 KB | Output isn't correct |
60 | Correct | 350 ms | 55800 KB | Output is correct |
61 | Correct | 539 ms | 55928 KB | Output is correct |
62 | Correct | 566 ms | 55800 KB | Output is correct |
63 | Correct | 515 ms | 55740 KB | Output is correct |
64 | Correct | 228 ms | 55672 KB | Output is correct |
65 | Incorrect | 345 ms | 55556 KB | Output isn't correct |
66 | Incorrect | 357 ms | 55544 KB | Output isn't correct |
67 | Incorrect | 400 ms | 55544 KB | Output isn't correct |
68 | Incorrect | 428 ms | 55672 KB | Output isn't correct |
69 | Incorrect | 266 ms | 55672 KB | Output isn't correct |
70 | Incorrect | 127 ms | 44664 KB | Output isn't correct |
71 | Incorrect | 206 ms | 55696 KB | Output isn't correct |
72 | Incorrect | 215 ms | 55672 KB | Output isn't correct |
73 | Incorrect | 284 ms | 55544 KB | Output isn't correct |
74 | Incorrect | 247 ms | 55596 KB | Output isn't correct |
75 | Incorrect | 232 ms | 55544 KB | Output isn't correct |
76 | Incorrect | 232 ms | 55672 KB | Output isn't correct |
77 | Incorrect | 261 ms | 55644 KB | Output isn't correct |
78 | Incorrect | 252 ms | 55544 KB | Output isn't correct |
79 | Incorrect | 137 ms | 55544 KB | Output isn't correct |
80 | Incorrect | 162 ms | 55544 KB | Output isn't correct |
81 | Incorrect | 146 ms | 55544 KB | Output isn't correct |
82 | Incorrect | 266 ms | 55596 KB | Output isn't correct |
83 | Incorrect | 261 ms | 55656 KB | Output isn't correct |
84 | Incorrect | 139 ms | 55592 KB | Output isn't correct |
85 | Incorrect | 253 ms | 55544 KB | Output isn't correct |
86 | Incorrect | 522 ms | 55672 KB | Output isn't correct |
87 | Incorrect | 242 ms | 55548 KB | Output isn't correct |
88 | Incorrect | 268 ms | 55544 KB | Output isn't correct |
89 | Incorrect | 365 ms | 55672 KB | Output isn't correct |
90 | Incorrect | 139 ms | 44576 KB | Output isn't correct |
91 | Incorrect | 289 ms | 55544 KB | Output isn't correct |
92 | Incorrect | 356 ms | 55416 KB | Output isn't correct |
93 | Incorrect | 499 ms | 55544 KB | Output isn't correct |
94 | Incorrect | 334 ms | 55548 KB | Output isn't correct |
95 | Incorrect | 286 ms | 55544 KB | Output isn't correct |
96 | Incorrect | 281 ms | 55544 KB | Output isn't correct |
97 | Incorrect | 469 ms | 55544 KB | Output isn't correct |
98 | Incorrect | 248 ms | 55544 KB | Output isn't correct |
99 | Incorrect | 320 ms | 55544 KB | Output isn't correct |
100 | Incorrect | 502 ms | 55468 KB | Output isn't correct |