답안 #400019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
400019 2021-05-07T06:56:54 Z syl123456 Bomb (IZhO17_bomb) C++17
81 / 100
531 ms 80752 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<vector<int>> h, w;
vector<int> lim;
void check(vector<string> v) {
    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 solve(vector<string> v) {
    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(v);
    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(v);
    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(v);
    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(v);
    int ans = 0;
    for (int i = 1; i <= mxh; ++i) lim[i] = min(lim[i], lim[i - 1]), ans = max(ans, i * lim[i]);
    return ans;
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> m;
    vector<string> v(n + 2, string(m + 2, '0')), v1(m + 2, string(n + 2, '0'));
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) cin >> v[i][j], v1[j][i] = v[i][j];
    cout << min(solve(v), solve(v1));
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Runtime error 2 ms 332 KB Execution killed with signal 11
3 Runtime error 2 ms 1184 KB Execution killed with signal 11
4 Runtime error 2 ms 1100 KB Execution killed with signal 11
5 Incorrect 1 ms 588 KB Output isn't correct
6 Runtime error 2 ms 648 KB Execution killed with signal 11
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Incorrect 1 ms 204 KB Output isn't correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Runtime error 1 ms 332 KB Execution killed with signal 11
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Incorrect 1 ms 336 KB Output isn't correct
18 Runtime error 2 ms 588 KB Execution killed with signal 11
19 Runtime error 2 ms 588 KB Execution killed with signal 11
20 Runtime error 1 ms 588 KB Execution killed with signal 11
21 Incorrect 1 ms 332 KB Output isn't correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Runtime error 1 ms 588 KB Execution killed with signal 11
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Runtime error 4 ms 2252 KB Execution killed with signal 11
28 Correct 8 ms 1728 KB Output is correct
29 Runtime error 6 ms 3276 KB Execution killed with signal 11
30 Correct 15 ms 2852 KB Output is correct
31 Correct 11 ms 2352 KB Output is correct
32 Runtime error 7 ms 4044 KB Execution killed with signal 11
33 Correct 15 ms 3040 KB Output is correct
34 Runtime error 4 ms 2380 KB Execution killed with signal 11
35 Correct 15 ms 3040 KB Output is correct
36 Correct 16 ms 3040 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 524 ms 80632 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Incorrect 60 ms 10332 KB Output isn't correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 2 ms 460 KB Output is correct
43 Correct 492 ms 80588 KB Output is correct
44 Correct 16 ms 3024 KB Output is correct
45 Correct 504 ms 80588 KB Output is correct
46 Correct 507 ms 80620 KB Output is correct
47 Correct 511 ms 80688 KB Output is correct
48 Correct 499 ms 80568 KB Output is correct
49 Correct 530 ms 80692 KB Output is correct
50 Correct 502 ms 80588 KB Output is correct
51 Correct 504 ms 80564 KB Output is correct
52 Correct 505 ms 80684 KB Output is correct
53 Correct 502 ms 80680 KB Output is correct
54 Correct 488 ms 80556 KB Output is correct
55 Correct 475 ms 80576 KB Output is correct
56 Correct 527 ms 80600 KB Output is correct
57 Correct 480 ms 80568 KB Output is correct
58 Correct 486 ms 80576 KB Output is correct
59 Correct 484 ms 80576 KB Output is correct
60 Correct 492 ms 80704 KB Output is correct
61 Correct 531 ms 80560 KB Output is correct
62 Correct 523 ms 80664 KB Output is correct
63 Correct 525 ms 80560 KB Output is correct
64 Correct 486 ms 80716 KB Output is correct
65 Correct 502 ms 80644 KB Output is correct
66 Correct 492 ms 80564 KB Output is correct
67 Correct 499 ms 80692 KB Output is correct
68 Correct 500 ms 80592 KB Output is correct
69 Correct 473 ms 80632 KB Output is correct
70 Correct 277 ms 51816 KB Output is correct
71 Correct 462 ms 80680 KB Output is correct
72 Correct 461 ms 80692 KB Output is correct
73 Correct 471 ms 80560 KB Output is correct
74 Correct 477 ms 80732 KB Output is correct
75 Correct 464 ms 80560 KB Output is correct
76 Correct 483 ms 80688 KB Output is correct
77 Correct 475 ms 80588 KB Output is correct
78 Correct 478 ms 80616 KB Output is correct
79 Correct 455 ms 80664 KB Output is correct
80 Correct 451 ms 80576 KB Output is correct
81 Correct 468 ms 80704 KB Output is correct
82 Correct 465 ms 80564 KB Output is correct
83 Correct 480 ms 80592 KB Output is correct
84 Correct 455 ms 80576 KB Output is correct
85 Correct 476 ms 80752 KB Output is correct
86 Correct 519 ms 80576 KB Output is correct
87 Correct 484 ms 80596 KB Output is correct
88 Correct 484 ms 80592 KB Output is correct
89 Correct 493 ms 80668 KB Output is correct
90 Correct 286 ms 51832 KB Output is correct
91 Correct 477 ms 80564 KB Output is correct
92 Correct 490 ms 80580 KB Output is correct
93 Correct 519 ms 80676 KB Output is correct
94 Correct 489 ms 80576 KB Output is correct
95 Correct 486 ms 80704 KB Output is correct
96 Correct 483 ms 80612 KB Output is correct
97 Correct 526 ms 80564 KB Output is correct
98 Correct 524 ms 80576 KB Output is correct
99 Correct 485 ms 80664 KB Output is correct
100 Correct 522 ms 80576 KB Output is correct