Submission #400018

# Submission time Handle Problem Language Result Execution time Memory
400018 2021-05-07T06:56:00 Z syl123456 Bomb (IZhO17_bomb) C++17
Compilation error
0 ms 0 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() {
    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();
    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]);
    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));
}

Compilation message

bomb.cpp: In function 'void check()':
bomb.cpp:24:17: error: 'v' was not declared in this scope
   24 |             if (v[i - 1][j] == '0' && v[i][j - 1] == '0') {
      |                 ^