답안 #915527

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915527 2024-01-24T06:23:46 Z vjudge1 Bomb (IZhO17_bomb) C++17
41 / 100
1000 ms 104628 KB
#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();    
    }           
}

Compilation message

bomb.cpp: In function 'void solve()':
bomb.cpp:35:9: warning: unused variable 'cnt' [-Wunused-variable]
   35 |     int cnt = 0;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 14 ms 58048 KB Output is correct
4 Correct 15 ms 57948 KB Output is correct
5 Correct 13 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2548 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 2 ms 2908 KB Output is correct
20 Correct 3 ms 2908 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Correct 2 ms 2908 KB Output is correct
23 Correct 3 ms 2908 KB Output is correct
24 Correct 2 ms 2908 KB Output is correct
25 Correct 4 ms 3056 KB Output is correct
26 Correct 4 ms 2904 KB Output is correct
27 Correct 68 ms 8540 KB Output is correct
28 Correct 84 ms 8792 KB Output is correct
29 Correct 148 ms 11352 KB Output is correct
30 Correct 216 ms 15760 KB Output is correct
31 Correct 162 ms 11384 KB Output is correct
32 Correct 159 ms 11728 KB Output is correct
33 Correct 261 ms 15632 KB Output is correct
34 Correct 44 ms 10840 KB Output is correct
35 Correct 186 ms 15628 KB Output is correct
36 Correct 338 ms 15632 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Execution timed out 1084 ms 104628 KB Time limit exceeded
39 Correct 1 ms 2396 KB Output is correct
40 Execution timed out 1075 ms 32860 KB Time limit exceeded
41 Correct 1 ms 2396 KB Output is correct
42 Correct 4 ms 2908 KB Output is correct
43 Execution timed out 1085 ms 104316 KB Time limit exceeded
44 Correct 329 ms 15644 KB Output is correct
45 Execution timed out 1014 ms 104360 KB Time limit exceeded
46 Execution timed out 1016 ms 104272 KB Time limit exceeded
47 Execution timed out 1012 ms 104360 KB Time limit exceeded
48 Execution timed out 1052 ms 104276 KB Time limit exceeded
49 Execution timed out 1022 ms 104464 KB Time limit exceeded
50 Execution timed out 1041 ms 104356 KB Time limit exceeded
51 Execution timed out 1059 ms 104276 KB Time limit exceeded
52 Execution timed out 1049 ms 104372 KB Time limit exceeded
53 Execution timed out 1061 ms 104352 KB Time limit exceeded
54 Execution timed out 1065 ms 104276 KB Time limit exceeded
55 Execution timed out 1061 ms 104532 KB Time limit exceeded
56 Execution timed out 1057 ms 104276 KB Time limit exceeded
57 Execution timed out 1039 ms 104272 KB Time limit exceeded
58 Execution timed out 1038 ms 104276 KB Time limit exceeded
59 Execution timed out 1052 ms 104276 KB Time limit exceeded
60 Execution timed out 1038 ms 104276 KB Time limit exceeded
61 Execution timed out 1043 ms 104460 KB Time limit exceeded
62 Execution timed out 1055 ms 104460 KB Time limit exceeded
63 Execution timed out 1010 ms 104528 KB Time limit exceeded
64 Execution timed out 1042 ms 104276 KB Time limit exceeded
65 Execution timed out 1074 ms 104280 KB Time limit exceeded
66 Execution timed out 1044 ms 104292 KB Time limit exceeded
67 Execution timed out 1060 ms 104368 KB Time limit exceeded
68 Execution timed out 1020 ms 104272 KB Time limit exceeded
69 Execution timed out 1036 ms 104272 KB Time limit exceeded
70 Execution timed out 1062 ms 84820 KB Time limit exceeded
71 Execution timed out 1057 ms 104372 KB Time limit exceeded
72 Execution timed out 1075 ms 104276 KB Time limit exceeded
73 Execution timed out 1064 ms 104276 KB Time limit exceeded
74 Execution timed out 1037 ms 104272 KB Time limit exceeded
75 Execution timed out 1014 ms 104360 KB Time limit exceeded
76 Execution timed out 1027 ms 104272 KB Time limit exceeded
77 Execution timed out 1066 ms 104364 KB Time limit exceeded
78 Execution timed out 1062 ms 104276 KB Time limit exceeded
79 Execution timed out 1066 ms 104276 KB Time limit exceeded
80 Execution timed out 1057 ms 104276 KB Time limit exceeded
81 Execution timed out 1047 ms 104272 KB Time limit exceeded
82 Execution timed out 1049 ms 104272 KB Time limit exceeded
83 Execution timed out 1010 ms 104356 KB Time limit exceeded
84 Execution timed out 1040 ms 104280 KB Time limit exceeded
85 Execution timed out 1061 ms 104276 KB Time limit exceeded
86 Execution timed out 1043 ms 104288 KB Time limit exceeded
87 Execution timed out 1070 ms 104372 KB Time limit exceeded
88 Execution timed out 1016 ms 104352 KB Time limit exceeded
89 Execution timed out 1020 ms 104272 KB Time limit exceeded
90 Execution timed out 1047 ms 84960 KB Time limit exceeded
91 Execution timed out 1072 ms 104364 KB Time limit exceeded
92 Execution timed out 1047 ms 104276 KB Time limit exceeded
93 Execution timed out 1039 ms 104308 KB Time limit exceeded
94 Execution timed out 1056 ms 104276 KB Time limit exceeded
95 Execution timed out 1029 ms 104272 KB Time limit exceeded
96 Execution timed out 1026 ms 104272 KB Time limit exceeded
97 Execution timed out 1042 ms 104276 KB Time limit exceeded
98 Execution timed out 1089 ms 104352 KB Time limit exceeded
99 Execution timed out 1062 ms 104352 KB Time limit exceeded
100 Execution timed out 1064 ms 104276 KB Time limit exceeded