Submission #38416

#TimeUsernameProblemLanguageResultExecution timeMemory
38416Just_Solve_The_ProblemBomb (IZhO17_bomb)C++14
3 / 100
1000 ms14272 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = (int)2505;

char c[N][N];
char ex[N][N];

main () {
//        #define NAME "bomb"
//    freopen(NAME".in", "r", stdin);
//    freopen(NAME".out", "w", stdout);
    int n, m; scanf ("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            char ss; ss = getchar();
            if (ss == '\n')
                j--;
            else {
                c[i][j] = ss;
            }
        }
    }
    int ans = 0;
    for (int h = 1; h <= n; h++) {
        for (int w = 1; w <= m; w++) {
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= m; j++)
                    ex[i][j] = c[i][j];

            bool can = 1;
            for (int i = 1; i <= n - h + 1; i++) {
                for (int j = 1; j <= m - w + 1; j++) {
                    can = 1;
                    for (int curi = i, k = 0; k < h && curi <= n; k++, curi++) {
                        for (int curj = j, l = 0; l < w && curj <= m; l++, curj++) {
                            if (ex[curi][curj] == '0') {
                                can = 0;
                                l = w; k = h;
                            }
                        }
                    }
                    if (can) {
                        for (int curi = i, k = 0; k < h && curi <= n; k++, curi++) {
                            for (int curj = j, l = 0; l < w && curj <= m; l++, curj++) {
                                if (ex[curi][curj] == '1')
                                    ex[curi][curj] = '2';
                            }
                        }
                    }
                }
            }
            can = 1;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (ex[i][j] == '1') can = 0;
                }
            }
            if (can) ans = max(ans, h * w);
        }
    }
    cout << ans;
}

Compilation message (stderr)

bomb.cpp:10:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
bomb.cpp: In function 'int main()':
bomb.cpp:14:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n, m; scanf ("%d %d", &n, &m);
                                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...