# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
38850 | 2018-01-07T08:58:19 Z | grumpy_gordon | Bomb (IZhO17_bomb) | C++14 | 596 ms | 61440 KB |
#include <iostream> #include <fstream> #include <set> #include <map> #include <string> #include <vector> #include <bitset> #include <algorithm> #include <cstring> #include <cstdlib> #include <cmath> #include <cassert> #include <queue> #define mp make_pair #define pb push_back typedef long long ll; typedef long double ld; using namespace std; const int MAXN = 2600; int n, m; char s[MAXN][MAXN]; int ans[MAXN]; int up[MAXN][MAXN]; int dw[MAXN][MAXN]; int main() { // freopen("bomb.in","r",stdin); // freopen("bomb.out","w",stdout); scanf("%d%d", &n, &m); for (int i = 0; i < n; ++i) scanf(" %s", s[i]); int mxh = n; int mxw = m; for (int i = 0; i < n; ++i) { int cnt = 0; for (int j = 0; j < m; ++j) { if (s[i][j] == '1') ++cnt; if (s[i][j] == '1' && (j == m - 1 || s[i][j + 1] == '0')) { mxw = min(mxw, cnt); cnt = 0; } } } for (int i = 0; i < m; ++i) { int cnt = 0; for (int j = 0; j < n; ++j) { if (s[j][i] == '1') ++cnt, up[j][i] = cnt; if (s[j][i] == '1' && (j == n - 1 || s[j + 1][i] == '0')) { mxh = min(mxh, cnt); cnt = 0; } } } for (int i = 0; i < m; ++i) { int cnt = 0; for (int j = n - 1; j >= 0; --j) { if (s[j][i] == '1') ++cnt, dw[j][i] = cnt; else cnt = 0; } } for (int i = 0; i <= mxw; ++i) ans[i] = MAXN; for (int i = 0; i < n; ++i) { int a = MAXN; int b = MAXN; int cnt = 0; for (int j = 0; j < m; ++j) { if (s[i][j] == '1') { a = min(a, up[i][j]); b = min(b, dw[i][j]); ++cnt; ans[cnt] = min(ans[cnt], a + b - 1); } else { a = MAXN; b = MAXN; cnt = 0; } } } for (int i = 0; i < n; ++i) { int a = MAXN; int b = MAXN; int cnt = 0; for (int j = m - 1; j >= 0; --j) { if (s[i][j] == '1') { a = min(a, up[i][j]); b = min(b, dw[i][j]); ++cnt; ans[cnt] = min(ans[cnt], a + b - 1); } else { a = MAXN; b = MAXN; cnt = 0; } } } int mh = 0; int mw = 0; for (int i = 1; i <= mxw; ++i) if (mh * mw < i * ans[i]) mw = i, mh = ans[i]; cout << mh * mw << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 61440 KB | Output is correct |
2 | Correct | 0 ms | 61440 KB | Output is correct |
3 | Correct | 0 ms | 61440 KB | Output is correct |
4 | Correct | 0 ms | 61440 KB | Output is correct |
5 | Correct | 0 ms | 61440 KB | Output is correct |
6 | Correct | 0 ms | 61440 KB | Output is correct |
7 | Incorrect | 0 ms | 61440 KB | Output isn't correct |
8 | Correct | 0 ms | 61440 KB | Output is correct |
9 | Correct | 0 ms | 61440 KB | Output is correct |
10 | Correct | 0 ms | 61440 KB | Output is correct |
11 | Correct | 0 ms | 61440 KB | Output is correct |
12 | Correct | 0 ms | 61440 KB | Output is correct |
13 | Correct | 0 ms | 61440 KB | Output is correct |
14 | Correct | 0 ms | 61440 KB | Output is correct |
15 | Correct | 0 ms | 61440 KB | Output is correct |
16 | Correct | 0 ms | 61440 KB | Output is correct |
17 | Correct | 0 ms | 61440 KB | Output is correct |
18 | Correct | 0 ms | 61440 KB | Output is correct |
19 | Correct | 0 ms | 61440 KB | Output is correct |
20 | Correct | 0 ms | 61440 KB | Output is correct |
21 | Correct | 0 ms | 61440 KB | Output is correct |
22 | Correct | 0 ms | 61440 KB | Output is correct |
23 | Correct | 0 ms | 61440 KB | Output is correct |
24 | Correct | 0 ms | 61440 KB | Output is correct |
25 | Correct | 0 ms | 61440 KB | Output is correct |
26 | Incorrect | 0 ms | 61440 KB | Output isn't correct |
27 | Incorrect | 0 ms | 61440 KB | Output isn't correct |
28 | Correct | 0 ms | 61440 KB | Output is correct |
29 | Correct | 6 ms | 61440 KB | Output is correct |
30 | Correct | 3 ms | 61440 KB | Output is correct |
31 | Correct | 0 ms | 61440 KB | Output is correct |
32 | Correct | 3 ms | 61440 KB | Output is correct |
33 | Correct | 3 ms | 61440 KB | Output is correct |
34 | Correct | 0 ms | 61440 KB | Output is correct |
35 | Correct | 0 ms | 61440 KB | Output is correct |
36 | Incorrect | 0 ms | 61440 KB | Output isn't correct |
37 | Correct | 0 ms | 61440 KB | Output is correct |
38 | Correct | 556 ms | 61440 KB | Output is correct |
39 | Correct | 0 ms | 61440 KB | Output is correct |
40 | Correct | 13 ms | 61440 KB | Output is correct |
41 | Correct | 0 ms | 61440 KB | Output is correct |
42 | Correct | 0 ms | 61440 KB | Output is correct |
43 | Correct | 366 ms | 61440 KB | Output is correct |
44 | Correct | 3 ms | 61440 KB | Output is correct |
45 | Correct | 356 ms | 61440 KB | Output is correct |
46 | Correct | 293 ms | 61440 KB | Output is correct |
47 | Correct | 329 ms | 61440 KB | Output is correct |
48 | Correct | 333 ms | 61440 KB | Output is correct |
49 | Incorrect | 539 ms | 61440 KB | Output isn't correct |
50 | Correct | 359 ms | 61440 KB | Output is correct |
51 | Correct | 323 ms | 61440 KB | Output is correct |
52 | Correct | 303 ms | 61440 KB | Output is correct |
53 | Correct | 303 ms | 61440 KB | Output is correct |
54 | Correct | 199 ms | 61440 KB | Output is correct |
55 | Correct | 199 ms | 61440 KB | Output is correct |
56 | Correct | 569 ms | 61440 KB | Output is correct |
57 | Correct | 196 ms | 61440 KB | Output is correct |
58 | Correct | 233 ms | 61440 KB | Output is correct |
59 | Correct | 216 ms | 61440 KB | Output is correct |
60 | Incorrect | 303 ms | 61440 KB | Output isn't correct |
61 | Incorrect | 563 ms | 61440 KB | Output isn't correct |
62 | Incorrect | 596 ms | 61440 KB | Output isn't correct |
63 | Incorrect | 506 ms | 61440 KB | Output isn't correct |
64 | Incorrect | 199 ms | 61440 KB | Output isn't correct |
65 | Correct | 303 ms | 61440 KB | Output is correct |
66 | Correct | 286 ms | 61440 KB | Output is correct |
67 | Correct | 389 ms | 61440 KB | Output is correct |
68 | Correct | 446 ms | 61440 KB | Output is correct |
69 | Correct | 213 ms | 61440 KB | Output is correct |
70 | Correct | 66 ms | 61440 KB | Output is correct |
71 | Correct | 199 ms | 61440 KB | Output is correct |
72 | Correct | 203 ms | 61440 KB | Output is correct |
73 | Correct | 193 ms | 61440 KB | Output is correct |
74 | Correct | 169 ms | 61440 KB | Output is correct |
75 | Correct | 186 ms | 61440 KB | Output is correct |
76 | Correct | 176 ms | 61440 KB | Output is correct |
77 | Correct | 219 ms | 61440 KB | Output is correct |
78 | Correct | 266 ms | 61440 KB | Output is correct |
79 | Correct | 93 ms | 61440 KB | Output is correct |
80 | Correct | 153 ms | 61440 KB | Output is correct |
81 | Correct | 116 ms | 61440 KB | Output is correct |
82 | Correct | 276 ms | 61440 KB | Output is correct |
83 | Correct | 223 ms | 61440 KB | Output is correct |
84 | Correct | 109 ms | 61440 KB | Output is correct |
85 | Correct | 179 ms | 61440 KB | Output is correct |
86 | Correct | 463 ms | 61440 KB | Output is correct |
87 | Correct | 199 ms | 61440 KB | Output is correct |
88 | Correct | 209 ms | 61440 KB | Output is correct |
89 | Correct | 273 ms | 61440 KB | Output is correct |
90 | Correct | 93 ms | 61440 KB | Output is correct |
91 | Correct | 209 ms | 61440 KB | Output is correct |
92 | Correct | 259 ms | 61440 KB | Output is correct |
93 | Correct | 529 ms | 61440 KB | Output is correct |
94 | Correct | 356 ms | 61440 KB | Output is correct |
95 | Correct | 196 ms | 61440 KB | Output is correct |
96 | Correct | 246 ms | 61440 KB | Output is correct |
97 | Correct | 473 ms | 61440 KB | Output is correct |
98 | Correct | 196 ms | 61440 KB | Output is correct |
99 | Correct | 306 ms | 61440 KB | Output is correct |
100 | Correct | 446 ms | 61440 KB | Output is correct |