Submission #936090

# Submission time Handle Problem Language Result Execution time Memory
936090 2024-03-01T06:18:32 Z guagua0407 Bomb (IZhO17_bomb) C++17
41 / 100
1000 ms 43348 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=0;
    int r=n;
    for(int len=1;len<=m;len++){
        while(r>=1 and !check(len,r)){
            r--;
        }
        //cout<<r<<'\n';
        ans=max(ans,len*r);
    }
    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();
      |          ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 73 ms 23832 KB Output is correct
4 Correct 67 ms 23644 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2508 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2652 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 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 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 2 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 2 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 4956 KB Output is correct
25 Correct 3 ms 4956 KB Output is correct
26 Correct 4 ms 4956 KB Output is correct
27 Correct 56 ms 8284 KB Output is correct
28 Correct 26 ms 8284 KB Output is correct
29 Correct 121 ms 8796 KB Output is correct
30 Correct 104 ms 9308 KB Output is correct
31 Correct 67 ms 8852 KB Output is correct
32 Correct 59 ms 9048 KB Output is correct
33 Correct 132 ms 9564 KB Output is correct
34 Correct 22 ms 8540 KB Output is correct
35 Correct 94 ms 9564 KB Output is correct
36 Correct 265 ms 9576 KB Output is correct
37 Correct 1 ms 2648 KB Output is correct
38 Execution timed out 1010 ms 43132 KB Time limit exceeded
39 Correct 1 ms 2652 KB Output is correct
40 Execution timed out 1091 ms 15072 KB Time limit exceeded
41 Correct 1 ms 2652 KB Output is correct
42 Correct 3 ms 4956 KB Output is correct
43 Execution timed out 1054 ms 43280 KB Time limit exceeded
44 Correct 194 ms 9560 KB Output is correct
45 Execution timed out 1062 ms 43348 KB Time limit exceeded
46 Execution timed out 1035 ms 43348 KB Time limit exceeded
47 Execution timed out 1055 ms 43348 KB Time limit exceeded
48 Execution timed out 1092 ms 43344 KB Time limit exceeded
49 Execution timed out 1048 ms 43140 KB Time limit exceeded
50 Execution timed out 1025 ms 43344 KB Time limit exceeded
51 Execution timed out 1006 ms 43344 KB Time limit exceeded
52 Execution timed out 1016 ms 43344 KB Time limit exceeded
53 Execution timed out 1027 ms 42668 KB Time limit exceeded
54 Execution timed out 1016 ms 42888 KB Time limit exceeded
55 Execution timed out 1059 ms 42076 KB Time limit exceeded
56 Execution timed out 1068 ms 42068 KB Time limit exceeded
57 Execution timed out 1065 ms 40572 KB Time limit exceeded
58 Execution timed out 1103 ms 40352 KB Time limit exceeded
59 Execution timed out 1033 ms 40532 KB Time limit exceeded
60 Execution timed out 1046 ms 40424 KB Time limit exceeded
61 Execution timed out 1049 ms 40596 KB Time limit exceeded
62 Execution timed out 1069 ms 40508 KB Time limit exceeded
63 Execution timed out 1025 ms 40552 KB Time limit exceeded
64 Execution timed out 1034 ms 40528 KB Time limit exceeded
65 Execution timed out 1066 ms 40576 KB Time limit exceeded
66 Execution timed out 1071 ms 40496 KB Time limit exceeded
67 Execution timed out 1064 ms 40532 KB Time limit exceeded
68 Execution timed out 1002 ms 40520 KB Time limit exceeded
69 Execution timed out 1020 ms 40528 KB Time limit exceeded
70 Execution timed out 1075 ms 33960 KB Time limit exceeded
71 Execution timed out 1074 ms 40424 KB Time limit exceeded
72 Execution timed out 1083 ms 40396 KB Time limit exceeded
73 Execution timed out 1098 ms 40532 KB Time limit exceeded
74 Execution timed out 1053 ms 40496 KB Time limit exceeded
75 Execution timed out 1040 ms 40528 KB Time limit exceeded
76 Execution timed out 1006 ms 40548 KB Time limit exceeded
77 Execution timed out 1042 ms 40532 KB Time limit exceeded
78 Execution timed out 1016 ms 40516 KB Time limit exceeded
79 Execution timed out 1064 ms 40532 KB Time limit exceeded
80 Execution timed out 1056 ms 40576 KB Time limit exceeded
81 Execution timed out 1035 ms 40528 KB Time limit exceeded
82 Execution timed out 1066 ms 40500 KB Time limit exceeded
83 Execution timed out 1004 ms 40352 KB Time limit exceeded
84 Execution timed out 1030 ms 40784 KB Time limit exceeded
85 Execution timed out 1012 ms 40384 KB Time limit exceeded
86 Execution timed out 1059 ms 40532 KB Time limit exceeded
87 Execution timed out 1088 ms 40444 KB Time limit exceeded
88 Execution timed out 1059 ms 40532 KB Time limit exceeded
89 Execution timed out 1063 ms 40532 KB Time limit exceeded
90 Execution timed out 1006 ms 33872 KB Time limit exceeded
91 Execution timed out 1042 ms 40532 KB Time limit exceeded
92 Execution timed out 1047 ms 40532 KB Time limit exceeded
93 Execution timed out 1042 ms 40528 KB Time limit exceeded
94 Execution timed out 1020 ms 40528 KB Time limit exceeded
95 Execution timed out 1036 ms 40740 KB Time limit exceeded
96 Execution timed out 1044 ms 40344 KB Time limit exceeded
97 Execution timed out 1056 ms 40532 KB Time limit exceeded
98 Execution timed out 1010 ms 40584 KB Time limit exceeded
99 Execution timed out 1033 ms 40532 KB Time limit exceeded
100 Execution timed out 1053 ms 40532 KB Time limit exceeded