# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51942 | 2018-06-22T17:21:41 Z | Nicksechko | Bomb (IZhO17_bomb) | C++14 | 4 ms | 772 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("input.txt","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] = mxh; 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; } } } for (int i = 1; i <= mxw; ++i) ans[i] = min(ans[i], ans[i - 1]); 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 376 KB | Output isn't correct |
2 | Incorrect | 3 ms | 472 KB | Output isn't correct |
3 | Incorrect | 3 ms | 532 KB | Output isn't correct |
4 | Incorrect | 3 ms | 564 KB | Output isn't correct |
5 | Incorrect | 3 ms | 564 KB | Output isn't correct |
6 | Incorrect | 2 ms | 564 KB | Output isn't correct |
7 | Incorrect | 2 ms | 564 KB | Output isn't correct |
8 | Incorrect | 3 ms | 624 KB | Output isn't correct |
9 | Incorrect | 2 ms | 624 KB | Output isn't correct |
10 | Incorrect | 2 ms | 624 KB | Output isn't correct |
11 | Incorrect | 2 ms | 624 KB | Output isn't correct |
12 | Incorrect | 2 ms | 624 KB | Output isn't correct |
13 | Incorrect | 2 ms | 624 KB | Output isn't correct |
14 | Incorrect | 3 ms | 624 KB | Output isn't correct |
15 | Incorrect | 2 ms | 624 KB | Output isn't correct |
16 | Incorrect | 2 ms | 624 KB | Output isn't correct |
17 | Incorrect | 2 ms | 624 KB | Output isn't correct |
18 | Incorrect | 2 ms | 624 KB | Output isn't correct |
19 | Incorrect | 2 ms | 636 KB | Output isn't correct |
20 | Incorrect | 2 ms | 636 KB | Output isn't correct |
21 | Incorrect | 3 ms | 636 KB | Output isn't correct |
22 | Incorrect | 2 ms | 636 KB | Output isn't correct |
23 | Incorrect | 2 ms | 636 KB | Output isn't correct |
24 | Incorrect | 3 ms | 636 KB | Output isn't correct |
25 | Incorrect | 2 ms | 636 KB | Output isn't correct |
26 | Incorrect | 3 ms | 636 KB | Output isn't correct |
27 | Incorrect | 3 ms | 636 KB | Output isn't correct |
28 | Incorrect | 2 ms | 760 KB | Output isn't correct |
29 | Incorrect | 2 ms | 760 KB | Output isn't correct |
30 | Incorrect | 2 ms | 760 KB | Output isn't correct |
31 | Incorrect | 2 ms | 760 KB | Output isn't correct |
32 | Incorrect | 2 ms | 760 KB | Output isn't correct |
33 | Incorrect | 2 ms | 760 KB | Output isn't correct |
34 | Incorrect | 2 ms | 760 KB | Output isn't correct |
35 | Incorrect | 2 ms | 760 KB | Output isn't correct |
36 | Incorrect | 2 ms | 760 KB | Output isn't correct |
37 | Incorrect | 2 ms | 760 KB | Output isn't correct |
38 | Incorrect | 2 ms | 760 KB | Output isn't correct |
39 | Incorrect | 2 ms | 760 KB | Output isn't correct |
40 | Incorrect | 2 ms | 760 KB | Output isn't correct |
41 | Incorrect | 2 ms | 760 KB | Output isn't correct |
42 | Incorrect | 2 ms | 760 KB | Output isn't correct |
43 | Incorrect | 2 ms | 760 KB | Output isn't correct |
44 | Incorrect | 2 ms | 760 KB | Output isn't correct |
45 | Incorrect | 2 ms | 760 KB | Output isn't correct |
46 | Incorrect | 2 ms | 760 KB | Output isn't correct |
47 | Incorrect | 2 ms | 760 KB | Output isn't correct |
48 | Incorrect | 2 ms | 760 KB | Output isn't correct |
49 | Incorrect | 2 ms | 760 KB | Output isn't correct |
50 | Incorrect | 2 ms | 760 KB | Output isn't correct |
51 | Incorrect | 2 ms | 760 KB | Output isn't correct |
52 | Incorrect | 2 ms | 760 KB | Output isn't correct |
53 | Incorrect | 2 ms | 760 KB | Output isn't correct |
54 | Incorrect | 2 ms | 760 KB | Output isn't correct |
55 | Incorrect | 2 ms | 760 KB | Output isn't correct |
56 | Incorrect | 2 ms | 760 KB | Output isn't correct |
57 | Incorrect | 2 ms | 760 KB | Output isn't correct |
58 | Incorrect | 2 ms | 760 KB | Output isn't correct |
59 | Incorrect | 2 ms | 760 KB | Output isn't correct |
60 | Incorrect | 3 ms | 760 KB | Output isn't correct |
61 | Incorrect | 3 ms | 760 KB | Output isn't correct |
62 | Incorrect | 2 ms | 760 KB | Output isn't correct |
63 | Incorrect | 2 ms | 760 KB | Output isn't correct |
64 | Incorrect | 3 ms | 760 KB | Output isn't correct |
65 | Incorrect | 3 ms | 760 KB | Output isn't correct |
66 | Incorrect | 2 ms | 760 KB | Output isn't correct |
67 | Incorrect | 3 ms | 760 KB | Output isn't correct |
68 | Incorrect | 2 ms | 760 KB | Output isn't correct |
69 | Incorrect | 2 ms | 760 KB | Output isn't correct |
70 | Incorrect | 3 ms | 760 KB | Output isn't correct |
71 | Incorrect | 3 ms | 760 KB | Output isn't correct |
72 | Incorrect | 2 ms | 760 KB | Output isn't correct |
73 | Incorrect | 2 ms | 760 KB | Output isn't correct |
74 | Incorrect | 3 ms | 772 KB | Output isn't correct |
75 | Incorrect | 3 ms | 772 KB | Output isn't correct |
76 | Incorrect | 2 ms | 772 KB | Output isn't correct |
77 | Incorrect | 3 ms | 772 KB | Output isn't correct |
78 | Incorrect | 2 ms | 772 KB | Output isn't correct |
79 | Incorrect | 2 ms | 772 KB | Output isn't correct |
80 | Incorrect | 2 ms | 772 KB | Output isn't correct |
81 | Incorrect | 3 ms | 772 KB | Output isn't correct |
82 | Incorrect | 2 ms | 772 KB | Output isn't correct |
83 | Incorrect | 3 ms | 772 KB | Output isn't correct |
84 | Incorrect | 3 ms | 772 KB | Output isn't correct |
85 | Incorrect | 3 ms | 772 KB | Output isn't correct |
86 | Incorrect | 2 ms | 772 KB | Output isn't correct |
87 | Incorrect | 2 ms | 772 KB | Output isn't correct |
88 | Incorrect | 2 ms | 772 KB | Output isn't correct |
89 | Incorrect | 2 ms | 772 KB | Output isn't correct |
90 | Incorrect | 2 ms | 772 KB | Output isn't correct |
91 | Incorrect | 2 ms | 772 KB | Output isn't correct |
92 | Incorrect | 2 ms | 772 KB | Output isn't correct |
93 | Incorrect | 2 ms | 772 KB | Output isn't correct |
94 | Incorrect | 2 ms | 772 KB | Output isn't correct |
95 | Incorrect | 2 ms | 772 KB | Output isn't correct |
96 | Incorrect | 2 ms | 772 KB | Output isn't correct |
97 | Incorrect | 2 ms | 772 KB | Output isn't correct |
98 | Incorrect | 2 ms | 772 KB | Output isn't correct |
99 | Incorrect | 2 ms | 772 KB | Output isn't correct |
100 | Incorrect | 2 ms | 772 KB | Output isn't correct |