답안 #935445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935445 2024-02-29T05:40:36 Z Darren0724 Bomb (IZhO17_bomb) C++17
41 / 100
1000 ms 74800 KB
#pragma GCC optimize("Ofast","O3","unroll-loops")
#pragma GCC target("avx","avx2")
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
int32_t main() {
    LCBorz;
    int n,m;cin>>n>>m;
    vector<vector<int>> v(n+1,vector<int>(m+1,0)),v1(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            char c;cin>>c;
            v[i][j]=v1[i][j]=(c=='0');
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            v1[i][j]+=v1[i-1][j]+v1[i][j-1]-v1[i-1][j-1];
        }
    }
    long long ans=0;
    int last=0;
    auto check=[&](int a,int b)->int {
        vector<vector<int>> pre(n+2,vector<int>(m+2,0));
        for(int i=a;i<=n;i++){
            for(int j=b;j<=m;j++){
                if(v1[i][j]-v1[i][j-b]-v1[i-a][j]+v1[i-a][j-b]==0){
                    pre[i-a+1][j-b+1]++;
                    pre[i+1][j-b+1]--;
                    pre[i-a+1][j+1]--;
                    pre[i+1][j+1]++;
                }
            }
        }
        int flag=1;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                pre[i][j]+=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1];
                if(v[i][j]==0&&pre[i][j]==0){
                    flag=0;
                }
            }
        }
        return flag;
    };
    for(int i=n;i>=1;i--){
        while(last+1<=m&&check(i,last+1)){
            last++;
        }
        ans=max(ans,1ll*last*i);
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 221 ms 856 KB Output is correct
4 Correct 203 ms 860 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 600 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 3 ms 592 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 4 ms 348 KB Output is correct
26 Correct 3 ms 348 KB Output is correct
27 Correct 73 ms 1424 KB Output is correct
28 Correct 89 ms 1804 KB Output is correct
29 Correct 203 ms 2120 KB Output is correct
30 Correct 300 ms 2724 KB Output is correct
31 Correct 186 ms 2272 KB Output is correct
32 Correct 204 ms 2356 KB Output is correct
33 Correct 354 ms 3168 KB Output is correct
34 Correct 79 ms 1468 KB Output is correct
35 Correct 339 ms 3240 KB Output is correct
36 Correct 317 ms 2888 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Execution timed out 1037 ms 74296 KB Time limit exceeded
39 Correct 0 ms 344 KB Output is correct
40 Execution timed out 1053 ms 10112 KB Time limit exceeded
41 Correct 0 ms 348 KB Output is correct
42 Correct 4 ms 592 KB Output is correct
43 Execution timed out 1058 ms 74296 KB Time limit exceeded
44 Correct 388 ms 3580 KB Output is correct
45 Execution timed out 1065 ms 74500 KB Time limit exceeded
46 Execution timed out 1010 ms 74640 KB Time limit exceeded
47 Execution timed out 1069 ms 74300 KB Time limit exceeded
48 Execution timed out 1058 ms 74364 KB Time limit exceeded
49 Execution timed out 1039 ms 74508 KB Time limit exceeded
50 Execution timed out 1025 ms 74384 KB Time limit exceeded
51 Execution timed out 1050 ms 74424 KB Time limit exceeded
52 Execution timed out 1056 ms 74440 KB Time limit exceeded
53 Execution timed out 1073 ms 74440 KB Time limit exceeded
54 Execution timed out 1067 ms 74468 KB Time limit exceeded
55 Execution timed out 1037 ms 74508 KB Time limit exceeded
56 Execution timed out 1030 ms 74456 KB Time limit exceeded
57 Execution timed out 1038 ms 74340 KB Time limit exceeded
58 Execution timed out 1043 ms 74612 KB Time limit exceeded
59 Execution timed out 1081 ms 74536 KB Time limit exceeded
60 Execution timed out 1046 ms 74388 KB Time limit exceeded
61 Execution timed out 1051 ms 74440 KB Time limit exceeded
62 Execution timed out 1035 ms 74452 KB Time limit exceeded
63 Execution timed out 1070 ms 74260 KB Time limit exceeded
64 Execution timed out 1059 ms 74508 KB Time limit exceeded
65 Execution timed out 1039 ms 74516 KB Time limit exceeded
66 Execution timed out 1033 ms 74584 KB Time limit exceeded
67 Execution timed out 1069 ms 74744 KB Time limit exceeded
68 Execution timed out 1022 ms 74248 KB Time limit exceeded
69 Execution timed out 1060 ms 74264 KB Time limit exceeded
70 Execution timed out 1038 ms 48028 KB Time limit exceeded
71 Execution timed out 1058 ms 74464 KB Time limit exceeded
72 Execution timed out 1055 ms 74424 KB Time limit exceeded
73 Execution timed out 1038 ms 74492 KB Time limit exceeded
74 Execution timed out 1057 ms 74532 KB Time limit exceeded
75 Execution timed out 1074 ms 74800 KB Time limit exceeded
76 Execution timed out 1040 ms 74284 KB Time limit exceeded
77 Execution timed out 1045 ms 74620 KB Time limit exceeded
78 Execution timed out 1054 ms 74280 KB Time limit exceeded
79 Execution timed out 1020 ms 74364 KB Time limit exceeded
80 Execution timed out 1056 ms 74376 KB Time limit exceeded
81 Execution timed out 1042 ms 74408 KB Time limit exceeded
82 Execution timed out 1053 ms 74520 KB Time limit exceeded
83 Execution timed out 1042 ms 74564 KB Time limit exceeded
84 Execution timed out 1066 ms 74296 KB Time limit exceeded
85 Execution timed out 1035 ms 74424 KB Time limit exceeded
86 Execution timed out 1049 ms 74584 KB Time limit exceeded
87 Execution timed out 1044 ms 74396 KB Time limit exceeded
88 Execution timed out 1035 ms 74672 KB Time limit exceeded
89 Execution timed out 1053 ms 74296 KB Time limit exceeded
90 Execution timed out 1039 ms 48276 KB Time limit exceeded
91 Execution timed out 1055 ms 74620 KB Time limit exceeded
92 Execution timed out 1032 ms 74384 KB Time limit exceeded
93 Execution timed out 1048 ms 74452 KB Time limit exceeded
94 Execution timed out 1060 ms 74488 KB Time limit exceeded
95 Execution timed out 1067 ms 74652 KB Time limit exceeded
96 Execution timed out 1052 ms 74484 KB Time limit exceeded
97 Execution timed out 1039 ms 74384 KB Time limit exceeded
98 Execution timed out 1052 ms 74524 KB Time limit exceeded
99 Execution timed out 1035 ms 74512 KB Time limit exceeded
100 Execution timed out 1075 ms 74416 KB Time limit exceeded