Submission #333923

# Submission time Handle Problem Language Result Execution time Memory
333923 2020-12-08T03:20:58 Z juggernaut Bomb (IZhO17_bomb) C++14
7 / 100
1000 ms 31156 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];
        }
    if(n<m){
        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 Incorrect 1 ms 492 KB Output isn't correct
3 Incorrect 10 ms 16492 KB Output isn't correct
4 Incorrect 11 ms 16492 KB Output isn't correct
5 Correct 8 ms 364 KB Output is correct
6 Correct 3 ms 404 KB Output is correct
7 Incorrect 1 ms 364 KB Output isn't correct
8 Incorrect 1 ms 492 KB Output isn't correct
9 Incorrect 1 ms 492 KB Output isn't correct
10 Incorrect 1 ms 364 KB Output isn't correct
11 Incorrect 1 ms 492 KB Output isn't correct
12 Incorrect 1 ms 364 KB Output isn't correct
13 Incorrect 1 ms 364 KB Output isn't correct
14 Incorrect 1 ms 364 KB Output isn't correct
15 Incorrect 1 ms 492 KB Output isn't correct
16 Incorrect 1 ms 492 KB Output isn't correct
17 Correct 5 ms 1004 KB Output is correct
18 Incorrect 1 ms 748 KB Output isn't correct
19 Incorrect 1 ms 1004 KB Output isn't correct
20 Incorrect 1 ms 1004 KB Output isn't correct
21 Correct 5 ms 876 KB Output is correct
22 Correct 9 ms 1132 KB Output is correct
23 Incorrect 2 ms 1004 KB Output isn't correct
24 Incorrect 2 ms 876 KB Output isn't correct
25 Incorrect 2 ms 1004 KB Output isn't correct
26 Incorrect 1 ms 1004 KB Output isn't correct
27 Incorrect 6 ms 2540 KB Output isn't correct
28 Correct 515 ms 4308 KB Output is correct
29 Incorrect 8 ms 3308 KB Output isn't correct
30 Execution timed out 1030 ms 6252 KB Time limit exceeded
31 Execution timed out 1002 ms 5064 KB Time limit exceeded
32 Incorrect 10 ms 3564 KB Output isn't correct
33 Incorrect 12 ms 4064 KB Output isn't correct
34 Incorrect 6 ms 2924 KB Output isn't correct
35 Incorrect 13 ms 4076 KB Output isn't correct
36 Incorrect 13 ms 4076 KB Output isn't correct
37 Incorrect 1 ms 492 KB Output isn't correct
38 Incorrect 337 ms 30948 KB Output isn't correct
39 Incorrect 1 ms 492 KB Output isn't correct
40 Execution timed out 1082 ms 15596 KB Time limit exceeded
41 Incorrect 1 ms 492 KB Output isn't correct
42 Incorrect 2 ms 1004 KB Output isn't correct
43 Incorrect 388 ms 31084 KB Output isn't correct
44 Incorrect 13 ms 4076 KB Output isn't correct
45 Incorrect 397 ms 30928 KB Output isn't correct
46 Incorrect 357 ms 30956 KB Output isn't correct
47 Incorrect 383 ms 30956 KB Output isn't correct
48 Incorrect 324 ms 31084 KB Output isn't correct
49 Incorrect 319 ms 30956 KB Output isn't correct
50 Incorrect 340 ms 30956 KB Output isn't correct
51 Incorrect 331 ms 30956 KB Output isn't correct
52 Incorrect 327 ms 30956 KB Output isn't correct
53 Incorrect 322 ms 30956 KB Output isn't correct
54 Incorrect 322 ms 31084 KB Output isn't correct
55 Incorrect 342 ms 31108 KB Output isn't correct
56 Incorrect 319 ms 30956 KB Output isn't correct
57 Incorrect 320 ms 30956 KB Output isn't correct
58 Incorrect 326 ms 31084 KB Output isn't correct
59 Incorrect 319 ms 30956 KB Output isn't correct
60 Incorrect 324 ms 30956 KB Output isn't correct
61 Incorrect 334 ms 31084 KB Output isn't correct
62 Incorrect 326 ms 31084 KB Output isn't correct
63 Incorrect 325 ms 31084 KB Output isn't correct
64 Incorrect 319 ms 30956 KB Output isn't correct
65 Incorrect 330 ms 31084 KB Output isn't correct
66 Incorrect 328 ms 31084 KB Output isn't correct
67 Incorrect 339 ms 31084 KB Output isn't correct
68 Incorrect 322 ms 30956 KB Output isn't correct
69 Incorrect 320 ms 31084 KB Output isn't correct
70 Incorrect 208 ms 24812 KB Output isn't correct
71 Incorrect 325 ms 30956 KB Output isn't correct
72 Incorrect 343 ms 31156 KB Output isn't correct
73 Incorrect 319 ms 30956 KB Output isn't correct
74 Incorrect 328 ms 31068 KB Output isn't correct
75 Incorrect 329 ms 30956 KB Output isn't correct
76 Incorrect 324 ms 30944 KB Output isn't correct
77 Incorrect 323 ms 30956 KB Output isn't correct
78 Incorrect 321 ms 30956 KB Output isn't correct
79 Incorrect 336 ms 30920 KB Output isn't correct
80 Incorrect 318 ms 30956 KB Output isn't correct
81 Incorrect 338 ms 30984 KB Output isn't correct
82 Incorrect 331 ms 31084 KB Output isn't correct
83 Incorrect 321 ms 30956 KB Output isn't correct
84 Incorrect 343 ms 31084 KB Output isn't correct
85 Incorrect 321 ms 30956 KB Output isn't correct
86 Incorrect 324 ms 30956 KB Output isn't correct
87 Incorrect 321 ms 31084 KB Output isn't correct
88 Incorrect 319 ms 30956 KB Output isn't correct
89 Incorrect 327 ms 30900 KB Output isn't correct
90 Incorrect 208 ms 24812 KB Output isn't correct
91 Incorrect 327 ms 30956 KB Output isn't correct
92 Incorrect 323 ms 31016 KB Output isn't correct
93 Incorrect 319 ms 30956 KB Output isn't correct
94 Incorrect 340 ms 30956 KB Output isn't correct
95 Incorrect 328 ms 30956 KB Output isn't correct
96 Incorrect 322 ms 31084 KB Output isn't correct
97 Incorrect 323 ms 31012 KB Output isn't correct
98 Incorrect 325 ms 30896 KB Output isn't correct
99 Incorrect 324 ms 31084 KB Output isn't correct
100 Incorrect 326 ms 30996 KB Output isn't correct