Submission #333922

# Submission time Handle Problem Language Result Execution time Memory
333922 2020-12-08T03:20:33 Z juggernaut Bomb (IZhO17_bomb) C++14
34 / 100
1000 ms 55660 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,mx,cnt[2505][2505],pref[2505][2505];
bool a[2505][2505];
char rd(){
    char ch;
    do{
        scanf("%c",&ch);
    }while(ch!='0'&&ch!='1');
    return ch;
}
bool sum(int x,int y,int x2,int y2){
    return (cnt[x2][y2]-cnt[x2][y-1]-cnt[x-1][y2]+cnt[x-1][y-1])==((x2-x+1)*(y2-y+1));
}
bool check(int x,int y){
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)pref[i][j]=0;
    for(int i=1;i+x-1<=n;i++)
        for(int j=1;j+y-1<=m;j++)
            if(sum(i,j,i+x-1,j+y-1)){
                for(int k=i;k<=i+x-1;k++)pref[k][j]++,pref[k][j+y]--;
            }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            pref[i][j]+=pref[i][j-1];
            if(a[i][j]&&!pref[i][j])return false;
        }
    }
    return true;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            a[i][j]=(rd()=='1');
            cnt[i][j]=cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1]+a[i][j];
        }
    for(int x=1;x<=m;x++){
        int l=1,r=n;
        while(l<r){
            int mid=(l+r+1)>>1;
            if(check(mid,x))l=mid;
            else r=mid-1;
        }
        if(!check(l,x))l=0;
        mx=max(mx,x*l);
    }
    printf("%d",mx);
}

Compilation message

bomb.cpp: In function 'char rd()':
bomb.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |         scanf("%c",&ch);
      |         ~~~~~^~~~~~~~~~
bomb.cpp: In function 'int main()':
bomb.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 22 ms 26604 KB Output is correct
4 Correct 22 ms 26476 KB Output is correct
5 Correct 8 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 5 ms 1004 KB Output is correct
18 Correct 4 ms 1132 KB Output is correct
19 Correct 8 ms 1388 KB Output is correct
20 Correct 9 ms 1388 KB Output is correct
21 Correct 5 ms 876 KB Output is correct
22 Correct 8 ms 1132 KB Output is correct
23 Correct 16 ms 1516 KB Output is correct
24 Correct 7 ms 1260 KB Output is correct
25 Correct 16 ms 1516 KB Output is correct
26 Correct 38 ms 1516 KB Output is correct
27 Correct 408 ms 4076 KB Output is correct
28 Correct 468 ms 4332 KB Output is correct
29 Execution timed out 1095 ms 5356 KB Time limit exceeded
30 Execution timed out 1089 ms 6252 KB Time limit exceeded
31 Execution timed out 1010 ms 5100 KB Time limit exceeded
32 Correct 818 ms 5996 KB Output is correct
33 Execution timed out 1096 ms 6636 KB Time limit exceeded
34 Correct 229 ms 4716 KB Output is correct
35 Execution timed out 1091 ms 6636 KB Time limit exceeded
36 Execution timed out 1080 ms 6636 KB Time limit exceeded
37 Correct 1 ms 492 KB Output is correct
38 Execution timed out 1091 ms 55532 KB Time limit exceeded
39 Correct 1 ms 492 KB Output is correct
40 Execution timed out 1087 ms 15596 KB Time limit exceeded
41 Correct 1 ms 492 KB Output is correct
42 Correct 34 ms 1516 KB Output is correct
43 Execution timed out 1101 ms 55404 KB Time limit exceeded
44 Execution timed out 1087 ms 6636 KB Time limit exceeded
45 Execution timed out 1084 ms 55532 KB Time limit exceeded
46 Execution timed out 1099 ms 55404 KB Time limit exceeded
47 Execution timed out 1097 ms 55532 KB Time limit exceeded
48 Execution timed out 1055 ms 55532 KB Time limit exceeded
49 Execution timed out 1054 ms 55404 KB Time limit exceeded
50 Execution timed out 1087 ms 55404 KB Time limit exceeded
51 Execution timed out 1046 ms 55420 KB Time limit exceeded
52 Execution timed out 1093 ms 55532 KB Time limit exceeded
53 Execution timed out 1086 ms 55460 KB Time limit exceeded
54 Execution timed out 1092 ms 55404 KB Time limit exceeded
55 Execution timed out 1100 ms 55528 KB Time limit exceeded
56 Execution timed out 1042 ms 55524 KB Time limit exceeded
57 Execution timed out 1102 ms 55576 KB Time limit exceeded
58 Execution timed out 1104 ms 55404 KB Time limit exceeded
59 Execution timed out 1102 ms 55404 KB Time limit exceeded
60 Execution timed out 1089 ms 55404 KB Time limit exceeded
61 Execution timed out 1058 ms 55480 KB Time limit exceeded
62 Execution timed out 1091 ms 55452 KB Time limit exceeded
63 Execution timed out 1100 ms 55516 KB Time limit exceeded
64 Execution timed out 1086 ms 55440 KB Time limit exceeded
65 Execution timed out 1094 ms 55404 KB Time limit exceeded
66 Execution timed out 1091 ms 55508 KB Time limit exceeded
67 Execution timed out 1073 ms 55404 KB Time limit exceeded
68 Execution timed out 1076 ms 55404 KB Time limit exceeded
69 Execution timed out 1097 ms 55612 KB Time limit exceeded
70 Execution timed out 1084 ms 44468 KB Time limit exceeded
71 Execution timed out 1070 ms 55532 KB Time limit exceeded
72 Execution timed out 1090 ms 55532 KB Time limit exceeded
73 Execution timed out 1087 ms 55404 KB Time limit exceeded
74 Execution timed out 1039 ms 55512 KB Time limit exceeded
75 Execution timed out 1092 ms 55404 KB Time limit exceeded
76 Execution timed out 1073 ms 55404 KB Time limit exceeded
77 Execution timed out 1096 ms 55404 KB Time limit exceeded
78 Execution timed out 1080 ms 55444 KB Time limit exceeded
79 Execution timed out 1088 ms 55636 KB Time limit exceeded
80 Execution timed out 1093 ms 55404 KB Time limit exceeded
81 Execution timed out 1093 ms 55532 KB Time limit exceeded
82 Execution timed out 1095 ms 55404 KB Time limit exceeded
83 Execution timed out 1091 ms 55600 KB Time limit exceeded
84 Execution timed out 1097 ms 55660 KB Time limit exceeded
85 Execution timed out 1094 ms 55456 KB Time limit exceeded
86 Execution timed out 1047 ms 55532 KB Time limit exceeded
87 Execution timed out 1095 ms 55660 KB Time limit exceeded
88 Execution timed out 1089 ms 55532 KB Time limit exceeded
89 Execution timed out 1069 ms 55404 KB Time limit exceeded
90 Execution timed out 1070 ms 44396 KB Time limit exceeded
91 Execution timed out 1086 ms 55604 KB Time limit exceeded
92 Execution timed out 1094 ms 55404 KB Time limit exceeded
93 Execution timed out 1071 ms 55496 KB Time limit exceeded
94 Execution timed out 1033 ms 55532 KB Time limit exceeded
95 Execution timed out 1038 ms 55532 KB Time limit exceeded
96 Execution timed out 1095 ms 55404 KB Time limit exceeded
97 Execution timed out 1040 ms 55404 KB Time limit exceeded
98 Execution timed out 1094 ms 55532 KB Time limit exceeded
99 Execution timed out 1093 ms 55404 KB Time limit exceeded
100 Execution timed out 1092 ms 55532 KB Time limit exceeded