답안 #400017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
400017 2021-05-07T06:37:20 Z syl123456 Bomb (IZhO17_bomb) C++17
99 / 100
319 ms 59268 KB
#include <bits/stdc++.h>
#define all(i) (i).begin(), (i).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl
using namespace std;
template<typename T1, typename T2>
ostream& operator << (ostream &i, pair<T1, T2> j) {
    return i << j.first << ' ' << j.second;
}
template<typename T>
ostream& operator << (ostream &i, vector<T> j) {
    i << '{' << j.size() << ':';
    for (T ii : j) i << ' ' << ii;
    return i << '}';
}
typedef long long ll;
typedef pair<int, int> pi;
int n, m, mxh, mxw;
vector<string> v;
vector<vector<int>> h, w;
vector<int> lim;
void check() {
    for (int i = 1; i <= n; ++i) {
        pi pre(0, 0);
        for (int j = 1; j <= m + 1; ++j) {
            if (v[i - 1][j] == '0' && v[i][j - 1] == '0') {
                pre = pi(j, min(mxh, h[i][j]));
                continue;
            }
            if (h[i][j] >= pre.second) continue;
            lim[h[i][j] + 1] = min(lim[h[i][j] + 1], j - pre.first);
            pre.second = h[i][j];
        }
    }
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> m;
    v.assign(n + 2, string(m + 2, '0'));
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) cin >> v[i][j];
    h.assign(n + 2, vector<int>(m + 2, 0));
    w.assign(n + 2, vector<int>(m + 2, 0));
    mxh = n, mxw = m;
    for (int i = n; i; --i) for (int j = m; j; --j) if (v[i][j] == '1') {
        h[i][j] = h[i + 1][j] + 1, w[i][j] = w[i][j + 1] + 1;
        if (v[i - 1][j] == '0') mxh = min(mxh, h[i][j]);
        if (v[i][j - 1] == '0') mxw = min(mxw, w[i][j]);
    }
    lim.assign(mxh + 2, mxw);
    check();
    for (int i = 1; i <= n; ++i) for (int _l = 1, _r = m; _l < _r; ++_l, --_r)
        swap(h[i][_l], h[i][_r]), swap(v[i][_l], v[i][_r]);
    check();
    for (int i = 1; i <= m; ++i) for (int _l = 1, _r = n; _l < _r; ++_l, --_r)
        swap(v[_l][i], v[_r][i]);
    h.assign(n + 2, vector<int>(m + 2, 0));
    for (int i = n; i; --i) for (int j = m; j; --j) if (v[i][j] == '1')
        h[i][j] = h[i + 1][j] + 1;
    check();
    for (int i = 1; i <= n; ++i) for (int _l = 1, _r = m; _l < _r; ++_l, --_r)
            swap(h[i][_l], h[i][_r]), swap(v[i][_l], v[i][_r]);
    check();
    int ans = 0;
    for (int i = 1; i <= mxh; ++i) lim[i] = min(lim[i], lim[i - 1]), ans = max(ans, i * lim[i]);
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 5 ms 1100 KB Output is correct
28 Correct 6 ms 1356 KB Output is correct
29 Correct 7 ms 1484 KB Output is correct
30 Correct 9 ms 2124 KB Output is correct
31 Correct 8 ms 1840 KB Output is correct
32 Correct 8 ms 1884 KB Output is correct
33 Correct 10 ms 2252 KB Output is correct
34 Correct 5 ms 1100 KB Output is correct
35 Correct 9 ms 2252 KB Output is correct
36 Correct 11 ms 2252 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 309 ms 59020 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Incorrect 33 ms 8012 KB Output isn't correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 298 ms 59108 KB Output is correct
44 Correct 10 ms 2252 KB Output is correct
45 Correct 293 ms 59228 KB Output is correct
46 Correct 301 ms 59048 KB Output is correct
47 Correct 305 ms 58948 KB Output is correct
48 Correct 297 ms 58920 KB Output is correct
49 Correct 305 ms 59108 KB Output is correct
50 Correct 296 ms 58920 KB Output is correct
51 Correct 296 ms 59076 KB Output is correct
52 Correct 293 ms 58948 KB Output is correct
53 Correct 288 ms 58948 KB Output is correct
54 Correct 287 ms 58924 KB Output is correct
55 Correct 284 ms 58920 KB Output is correct
56 Correct 306 ms 59076 KB Output is correct
57 Correct 285 ms 59044 KB Output is correct
58 Correct 289 ms 59040 KB Output is correct
59 Correct 285 ms 59240 KB Output is correct
60 Correct 289 ms 59048 KB Output is correct
61 Correct 306 ms 59040 KB Output is correct
62 Correct 302 ms 59008 KB Output is correct
63 Correct 306 ms 58996 KB Output is correct
64 Correct 287 ms 58996 KB Output is correct
65 Correct 287 ms 59100 KB Output is correct
66 Correct 298 ms 59120 KB Output is correct
67 Correct 296 ms 58996 KB Output is correct
68 Correct 303 ms 58936 KB Output is correct
69 Correct 281 ms 58936 KB Output is correct
70 Correct 172 ms 37956 KB Output is correct
71 Correct 277 ms 59112 KB Output is correct
72 Correct 286 ms 58964 KB Output is correct
73 Correct 288 ms 59268 KB Output is correct
74 Correct 283 ms 59076 KB Output is correct
75 Correct 285 ms 59156 KB Output is correct
76 Correct 293 ms 59152 KB Output is correct
77 Correct 285 ms 58972 KB Output is correct
78 Correct 284 ms 59128 KB Output is correct
79 Correct 276 ms 59032 KB Output is correct
80 Correct 270 ms 59036 KB Output is correct
81 Correct 276 ms 59016 KB Output is correct
82 Correct 287 ms 58948 KB Output is correct
83 Correct 288 ms 59076 KB Output is correct
84 Correct 278 ms 59148 KB Output is correct
85 Correct 285 ms 59004 KB Output is correct
86 Correct 319 ms 59004 KB Output is correct
87 Correct 289 ms 59052 KB Output is correct
88 Correct 282 ms 59072 KB Output is correct
89 Correct 284 ms 59040 KB Output is correct
90 Correct 170 ms 38224 KB Output is correct
91 Correct 280 ms 59032 KB Output is correct
92 Correct 289 ms 58952 KB Output is correct
93 Correct 306 ms 59076 KB Output is correct
94 Correct 286 ms 59036 KB Output is correct
95 Correct 278 ms 58896 KB Output is correct
96 Correct 284 ms 58624 KB Output is correct
97 Correct 287 ms 58540 KB Output is correct
98 Correct 277 ms 58592 KB Output is correct
99 Correct 276 ms 58588 KB Output is correct
100 Correct 292 ms 58432 KB Output is correct