답안 #936098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936098 2024-03-01T06:35:03 Z guagua0407 Bomb (IZhO17_bomb) C++17
41 / 100
1000 ms 37460 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define all(x) x.begin(),x.end()

const int mxn=2505;
char c[mxn][mxn];
int pre[mxn][mxn];
bool used[mxn][mxn];
int mn[mxn];
int n,m;

bool check(int x,int y){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            used[i][j]=false;
        }
    }
    for(int j=1;j<=m;j++){
        mn[j]=0;
    }
    int cur=0;
    for(int i=y;i<=n;i++){
        int prv=0;
        for(int j=x;j<=m;j++){
            int sum=pre[i][j]-pre[i][j-x]-pre[i-y][j]+pre[i-y][j-x];
            if(sum!=x*y){
                continue;
            }
            for(int k=max(prv+1,j-x+1);k<=j;k++){
                for(int l=i;l>=max(mn[k]+1,i-y+1);l--){
                    used[l][k]=true;
                    cur++;
                }
                mn[k]=i;
            }
            prv=j;
        }
    }
    return cur==pre[n][m];
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    auto st=clock();
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>c[i][j];
            pre[i][j]=pre[i][j-1]+pre[i-1][j]-pre[i-1][j-1]+(c[i][j]=='1');
        }
    }
    int ans=1;
    for(int len=m;len>=1;len--){
        int r=(ans+len-1)/len;
        while(r<=n and check(len,r)){
            r++;
        }
        ans=max(ans,len*(r-1));
    }
    cout<<ans<<'\n';
}

Compilation message

bomb.cpp: In function 'int main()':
bomb.cpp:49:10: warning: unused variable 'st' [-Wunused-variable]
   49 |     auto st=clock();
      |          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 8 ms 23768 KB Output is correct
4 Correct 9 ms 23644 KB Output is correct
5 Correct 7 ms 2552 KB Output is correct
6 Correct 3 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2652 KB Output is correct
17 Correct 1 ms 2908 KB Output is correct
18 Correct 1 ms 2908 KB Output is correct
19 Correct 1 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 5 ms 4956 KB Output is correct
27 Correct 70 ms 8284 KB Output is correct
28 Correct 32 ms 8280 KB Output is correct
29 Correct 119 ms 8836 KB Output is correct
30 Correct 79 ms 9052 KB Output is correct
31 Correct 56 ms 8540 KB Output is correct
32 Correct 46 ms 8796 KB Output is correct
33 Correct 85 ms 9376 KB Output is correct
34 Correct 16 ms 8548 KB Output is correct
35 Correct 66 ms 9308 KB Output is correct
36 Correct 399 ms 9372 KB Output is correct
37 Correct 1 ms 2652 KB Output is correct
38 Execution timed out 1092 ms 37020 KB Time limit exceeded
39 Correct 1 ms 2652 KB Output is correct
40 Execution timed out 1087 ms 14172 KB Time limit exceeded
41 Correct 1 ms 2648 KB Output is correct
42 Correct 3 ms 4956 KB Output is correct
43 Execution timed out 1010 ms 37200 KB Time limit exceeded
44 Correct 150 ms 9372 KB Output is correct
45 Execution timed out 1039 ms 37008 KB Time limit exceeded
46 Execution timed out 1037 ms 37020 KB Time limit exceeded
47 Execution timed out 1080 ms 37028 KB Time limit exceeded
48 Execution timed out 1047 ms 37256 KB Time limit exceeded
49 Execution timed out 1020 ms 37204 KB Time limit exceeded
50 Execution timed out 1020 ms 37200 KB Time limit exceeded
51 Execution timed out 1037 ms 37200 KB Time limit exceeded
52 Execution timed out 1055 ms 37004 KB Time limit exceeded
53 Execution timed out 1022 ms 37200 KB Time limit exceeded
54 Execution timed out 1046 ms 37016 KB Time limit exceeded
55 Execution timed out 1042 ms 37200 KB Time limit exceeded
56 Execution timed out 1030 ms 37204 KB Time limit exceeded
57 Execution timed out 1055 ms 37024 KB Time limit exceeded
58 Execution timed out 1064 ms 37200 KB Time limit exceeded
59 Execution timed out 1050 ms 37460 KB Time limit exceeded
60 Execution timed out 1075 ms 37028 KB Time limit exceeded
61 Execution timed out 1066 ms 37204 KB Time limit exceeded
62 Execution timed out 1031 ms 37024 KB Time limit exceeded
63 Execution timed out 1070 ms 37020 KB Time limit exceeded
64 Execution timed out 1050 ms 37204 KB Time limit exceeded
65 Execution timed out 1064 ms 37024 KB Time limit exceeded
66 Execution timed out 1045 ms 37032 KB Time limit exceeded
67 Execution timed out 1045 ms 37200 KB Time limit exceeded
68 Execution timed out 1046 ms 37012 KB Time limit exceeded
69 Execution timed out 1045 ms 37112 KB Time limit exceeded
70 Execution timed out 1059 ms 31572 KB Time limit exceeded
71 Execution timed out 1064 ms 37204 KB Time limit exceeded
72 Execution timed out 1018 ms 37020 KB Time limit exceeded
73 Execution timed out 1049 ms 37200 KB Time limit exceeded
74 Execution timed out 1036 ms 37200 KB Time limit exceeded
75 Execution timed out 1035 ms 37204 KB Time limit exceeded
76 Execution timed out 1052 ms 37204 KB Time limit exceeded
77 Execution timed out 1080 ms 37008 KB Time limit exceeded
78 Execution timed out 1063 ms 37024 KB Time limit exceeded
79 Execution timed out 1054 ms 37200 KB Time limit exceeded
80 Execution timed out 1041 ms 37260 KB Time limit exceeded
81 Execution timed out 1064 ms 37204 KB Time limit exceeded
82 Execution timed out 1062 ms 37204 KB Time limit exceeded
83 Execution timed out 1050 ms 37204 KB Time limit exceeded
84 Execution timed out 1054 ms 37200 KB Time limit exceeded
85 Execution timed out 1048 ms 37424 KB Time limit exceeded
86 Execution timed out 1069 ms 37036 KB Time limit exceeded
87 Execution timed out 1065 ms 37204 KB Time limit exceeded
88 Execution timed out 1067 ms 37204 KB Time limit exceeded
89 Execution timed out 1063 ms 37204 KB Time limit exceeded
90 Execution timed out 1030 ms 31568 KB Time limit exceeded
91 Execution timed out 1060 ms 37016 KB Time limit exceeded
92 Execution timed out 1061 ms 37204 KB Time limit exceeded
93 Execution timed out 1024 ms 37200 KB Time limit exceeded
94 Execution timed out 1040 ms 37224 KB Time limit exceeded
95 Execution timed out 1067 ms 37204 KB Time limit exceeded
96 Execution timed out 1020 ms 37200 KB Time limit exceeded
97 Execution timed out 1093 ms 37024 KB Time limit exceeded
98 Execution timed out 1038 ms 37016 KB Time limit exceeded
99 Execution timed out 1022 ms 37200 KB Time limit exceeded
100 Execution timed out 1037 ms 37140 KB Time limit exceeded