답안 #171598

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171598 2019-12-29T10:39:59 Z mcdx9524 Bomb (IZhO17_bomb) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2500 + 7;

char a[N][N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    if (n == 1 || m == 1) {
        vector <int> aa;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                char x;
                cin >> x;
                aa.push_back(x - '0');
            }
        }
        int cnt = 1;
        int res = 1e9;
        for (int i = 1; i < max(n, m); i++) {
            if (aa[i] != aa[i - 1]) {
                if (aa[i - 1] == 1) {
                    res = min(res, cnt);
                }
                cnt = 0;
            }
            cnt++;
        }
        if (aa[max(n, m) - 1] == 1) {
            res = min(res, cnt);
        }
        cout << res << '\n';
        return 0;
    }
    if (max(n, m) > 100) {
        //assert(0);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int x = 1; x <= n; x++) {
        int bl = 1, br = m;
        while (bl <= br) {
            int y = (bl + br) / 2;
            char b[n + 7][m + 7];
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    b[i][j] = a[i][j];
                }
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (i + x - 1 > n || j + y - 1 > m) {
                        continue;
                    }
                    bool bad = false;
                    for (int r = i; r <= i + x - 1; r++) {
                        for (int c = j; c <= j + y - 1; c++) {
                            if (b[r][c] == '0') {
                                bad = true;
                            }
                            if (bad) break;
                        }
                        if (bad) break;
                    }
                    if (bad) continue;
                    for (int r = i; r <= i + x - 1; r++) {
                        for (int c = j; c <= j + y - 1; c++) {
                            b[r][c] = '2';
                        }
                    }
                }
            }
            bool good = true;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (a[i][j] == '0') {
                        continue;
                    }
                    if (a[i][j] == '1' && b[i][j] == '2') {
                        continue;
                    }
                    good = false;
                    if (!good) break;
                }
                if (!good) break;
            }
            if (good) {
                bl = y + 1;
                ans = max(ans, x * y);
            } else {
                br = y - 1;
            }
    }
    cout << ans << '\n';
    return 0;
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:107:1: error: expected '}' at end of input
 }
 ^