제출 #915527

#제출 시각아이디문제언어결과실행 시간메모리
915527vjudge1Bomb (IZhO17_bomb)C++17
41 / 100
1089 ms104628 KiB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")

#include <bits/stdc++.h>
 
#define int long long 
#define pb push_back
#define ui unsigned int
#define ld long double
#define pl pair<long long int,  long long int>
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ff first    
#define ss second
#define sz size()
#define all(x) x.begin(), x.end()
 
using namespace std;
 
const int maxn = 1e6 + 11;
const int inf = 1e17 + 1;
const int mod = 1e9 + 7;
// const int mod = 998244353;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1 , 0, -1, 1, -1, 1};
const double eps = 1e-10;

int n, m;

int pr[2501][2501], p[2501][2501];

void solve() {
    cin >> n >> m;

    char ch[n + 1][m + 1];
    int cnt = 0;

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> ch[ i ][ j ];
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            pr[ i ][ j ] = pr[i - 1][ j ] + pr[ i ][j - 1] - pr[i - 1][j - 1] + (ch[ i ][ j ] - '0');
        }
    }
    int y = m;
    int x = 1;
    int ans = 0;

    while(x <= n && y) {
        while(y) {
            for(int i = 0; i <= n; i++) {
                for(int j = 0; j <= m; j++) {
                    p[ i ][ j ] = 0;
                }
            }
            for(int i = 0; i + x <= n; i++) {
                for(int j = 0; j + y <= m; j++) {
                    int c = pr[i + x][j + y] - pr[i + x][ j ] - pr[ i ][j + y] + pr[ i ][ j ];

                    if(c == x * y) {
                        p[i + x + 1][j + y + 1]++;
                        p[i + 1][j + y + 1]--;
                        p[i + x + 1][j + 1]--;
                        p[i + 1][j + 1]++;
                    }
                }
            }

            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= m; j++) {
                    p[ i ][ j ] += p[i - 1][ j ] + p[ i ][j - 1] - p[i - 1][j - 1];
                }
            }
            bool fl = true;
            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= m; j++) {
                    if(ch[ i ][ j ] == '1' && p[ i ][ j ] == 0) {
                        fl = false;
                    }
                }
            }
            if(fl) {
                break;
            }
            y--;
        }
        ans = max(ans, x * y);
        x++;
    }
    cout << ans;
}
    
signed main() {
    // freopen("sum.in", "r", stdin); 
    // freopen("sum.out", "w", stdout);
 
    boost;      

    int tt = 1;

    // cin >> tt;

    for(int i = 1; i <= tt; i++) {
        // cout << "Case " << i << ":\n";
        solve();    
    }           
}

컴파일 시 표준 에러 (stderr) 메시지

bomb.cpp: In function 'void solve()':
bomb.cpp:35:9: warning: unused variable 'cnt' [-Wunused-variable]
   35 |     int cnt = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...