Submission #936113

# Submission time Handle Problem Language Result Execution time Memory
936113 2024-03-01T07:03:31 Z guagua0407 Bomb (IZhO17_bomb) C++17
36 / 100
252 ms 22868 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;
    assert(n<=450);
    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;
    set<int> S;
    for(int len=1;len<=m;len++){
        while(r>=1 and !check(len,r)){
            r--;
        }
        S.insert(r);
        //cout<<r<<'\n';
        ans=max(ans,len*r);
    }
    assert((int)S.size()<20);
    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 2652 KB Output is correct
3 Runtime error 3 ms 604 KB Execution killed with signal 6
4 Runtime error 2 ms 604 KB Execution killed with signal 6
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2516 KB Output is correct
8 Correct 2 ms 2424 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 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2400 KB Output is correct
16 Correct 1 ms 2656 KB Output is correct
17 Correct 1 ms 2904 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 3 ms 4960 KB Output is correct
20 Correct 2 ms 4964 KB Output is correct
21 Correct 1 ms 2656 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 2 ms 4960 KB Output is correct
24 Correct 2 ms 4952 KB Output is correct
25 Correct 4 ms 4952 KB Output is correct
26 Correct 6 ms 4956 KB Output is correct
27 Correct 57 ms 8344 KB Output is correct
28 Correct 24 ms 8504 KB Output is correct
29 Runtime error 132 ms 17656 KB Execution killed with signal 6
30 Correct 112 ms 9420 KB Output is correct
31 Correct 74 ms 8840 KB Output is correct
32 Correct 62 ms 9048 KB Output is correct
33 Correct 132 ms 11352 KB Output is correct
34 Correct 32 ms 8540 KB Output is correct
35 Correct 92 ms 11352 KB Output is correct
36 Correct 252 ms 11540 KB Output is correct
37 Correct 1 ms 2652 KB Output is correct
38 Runtime error 2 ms 576 KB Execution killed with signal 6
39 Correct 1 ms 2652 KB Output is correct
40 Runtime error 1 ms 604 KB Execution killed with signal 6
41 Correct 1 ms 2652 KB Output is correct
42 Runtime error 9 ms 10076 KB Execution killed with signal 6
43 Runtime error 2 ms 604 KB Execution killed with signal 6
44 Runtime error 215 ms 22868 KB Execution killed with signal 6
45 Runtime error 1 ms 600 KB Execution killed with signal 6
46 Runtime error 2 ms 476 KB Execution killed with signal 6
47 Runtime error 1 ms 600 KB Execution killed with signal 6
48 Runtime error 1 ms 604 KB Execution killed with signal 6
49 Runtime error 2 ms 604 KB Execution killed with signal 6
50 Runtime error 3 ms 600 KB Execution killed with signal 6
51 Runtime error 1 ms 604 KB Execution killed with signal 6
52 Runtime error 2 ms 604 KB Execution killed with signal 6
53 Runtime error 1 ms 604 KB Execution killed with signal 6
54 Runtime error 3 ms 600 KB Execution killed with signal 6
55 Runtime error 2 ms 600 KB Execution killed with signal 6
56 Runtime error 2 ms 604 KB Execution killed with signal 6
57 Runtime error 2 ms 604 KB Execution killed with signal 6
58 Runtime error 3 ms 600 KB Execution killed with signal 6
59 Runtime error 1 ms 604 KB Execution killed with signal 6
60 Runtime error 1 ms 604 KB Execution killed with signal 6
61 Runtime error 1 ms 604 KB Execution killed with signal 6
62 Runtime error 1 ms 604 KB Execution killed with signal 6
63 Runtime error 1 ms 600 KB Execution killed with signal 6
64 Runtime error 2 ms 604 KB Execution killed with signal 6
65 Runtime error 1 ms 604 KB Execution killed with signal 6
66 Runtime error 1 ms 604 KB Execution killed with signal 6
67 Runtime error 2 ms 600 KB Execution killed with signal 6
68 Runtime error 1 ms 604 KB Execution killed with signal 6
69 Runtime error 1 ms 604 KB Execution killed with signal 6
70 Runtime error 2 ms 604 KB Execution killed with signal 6
71 Runtime error 2 ms 604 KB Execution killed with signal 6
72 Runtime error 1 ms 480 KB Execution killed with signal 6
73 Runtime error 1 ms 604 KB Execution killed with signal 6
74 Runtime error 1 ms 604 KB Execution killed with signal 6
75 Runtime error 1 ms 604 KB Execution killed with signal 6
76 Runtime error 2 ms 604 KB Execution killed with signal 6
77 Runtime error 2 ms 604 KB Execution killed with signal 6
78 Runtime error 2 ms 600 KB Execution killed with signal 6
79 Runtime error 1 ms 572 KB Execution killed with signal 6
80 Runtime error 2 ms 608 KB Execution killed with signal 6
81 Runtime error 2 ms 612 KB Execution killed with signal 6
82 Runtime error 2 ms 612 KB Execution killed with signal 6
83 Runtime error 2 ms 608 KB Execution killed with signal 6
84 Runtime error 1 ms 612 KB Execution killed with signal 6
85 Runtime error 1 ms 608 KB Execution killed with signal 6
86 Runtime error 2 ms 612 KB Execution killed with signal 6
87 Runtime error 1 ms 612 KB Execution killed with signal 6
88 Runtime error 2 ms 604 KB Execution killed with signal 6
89 Runtime error 2 ms 612 KB Execution killed with signal 6
90 Runtime error 1 ms 604 KB Execution killed with signal 6
91 Runtime error 2 ms 600 KB Execution killed with signal 6
92 Runtime error 1 ms 604 KB Execution killed with signal 6
93 Runtime error 2 ms 600 KB Execution killed with signal 6
94 Runtime error 2 ms 604 KB Execution killed with signal 6
95 Runtime error 2 ms 600 KB Execution killed with signal 6
96 Runtime error 2 ms 608 KB Execution killed with signal 6
97 Runtime error 2 ms 604 KB Execution killed with signal 6
98 Runtime error 1 ms 604 KB Execution killed with signal 6
99 Runtime error 2 ms 604 KB Execution killed with signal 6
100 Runtime error 1 ms 600 KB Execution killed with signal 6