# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
334003 |
2020-12-08T05:20:12 Z |
juggernaut |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
56816 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;
}
bool check_1(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=j;k<=j+y-1;k++)pref[i][k]++,pref[i+x][k]--;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
pref[i][j]+=pref[i-1][j];
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_1(mid,x))l=mid;
else r=mid-1;
}
if(!check_1(l,x))l=0;
mx=max(mx,x*l);
}
printf("%d",mx);
// }else{
// for(int x=1;x<=n;x++){
// int l=1,r=m;
// while(l<r){
// int mid=(l+r+1)>>1;
// if(check_1(x,mid))l=mid;
// else r=mid-1;
// }
// if(!check_1(x,l))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:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
48 | 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 |
18 ms |
26604 KB |
Output is correct |
4 |
Correct |
17 ms |
26516 KB |
Output is correct |
5 |
Correct |
77 ms |
428 KB |
Output is correct |
6 |
Correct |
73 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 |
1520 KB |
Output is correct |
24 |
Correct |
7 ms |
1260 KB |
Output is correct |
25 |
Correct |
17 ms |
1516 KB |
Output is correct |
26 |
Correct |
90 ms |
1516 KB |
Output is correct |
27 |
Execution timed out |
1083 ms |
4076 KB |
Time limit exceeded |
28 |
Correct |
488 ms |
4308 KB |
Output is correct |
29 |
Execution timed out |
1053 ms |
5356 KB |
Time limit exceeded |
30 |
Execution timed out |
1045 ms |
6252 KB |
Time limit exceeded |
31 |
Execution timed out |
1087 ms |
4972 KB |
Time limit exceeded |
32 |
Correct |
820 ms |
5876 KB |
Output is correct |
33 |
Execution timed out |
1087 ms |
6636 KB |
Time limit exceeded |
34 |
Correct |
241 ms |
4716 KB |
Output is correct |
35 |
Execution timed out |
1088 ms |
6636 KB |
Time limit exceeded |
36 |
Execution timed out |
1070 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 |
640 KB |
Output is correct |
40 |
Execution timed out |
1088 ms |
15596 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
492 KB |
Output is correct |
42 |
Correct |
35 ms |
1516 KB |
Output is correct |
43 |
Execution timed out |
1089 ms |
55532 KB |
Time limit exceeded |
44 |
Execution timed out |
1071 ms |
6636 KB |
Time limit exceeded |
45 |
Execution timed out |
1089 ms |
56172 KB |
Time limit exceeded |
46 |
Execution timed out |
1092 ms |
56096 KB |
Time limit exceeded |
47 |
Execution timed out |
1099 ms |
56160 KB |
Time limit exceeded |
48 |
Execution timed out |
1090 ms |
56300 KB |
Time limit exceeded |
49 |
Execution timed out |
1099 ms |
56300 KB |
Time limit exceeded |
50 |
Execution timed out |
1050 ms |
56300 KB |
Time limit exceeded |
51 |
Execution timed out |
1090 ms |
56300 KB |
Time limit exceeded |
52 |
Execution timed out |
1102 ms |
56156 KB |
Time limit exceeded |
53 |
Execution timed out |
1099 ms |
56368 KB |
Time limit exceeded |
54 |
Execution timed out |
1084 ms |
55488 KB |
Time limit exceeded |
55 |
Execution timed out |
1083 ms |
55660 KB |
Time limit exceeded |
56 |
Execution timed out |
1024 ms |
56812 KB |
Time limit exceeded |
57 |
Execution timed out |
1084 ms |
56688 KB |
Time limit exceeded |
58 |
Execution timed out |
1103 ms |
56684 KB |
Time limit exceeded |
59 |
Execution timed out |
1094 ms |
56752 KB |
Time limit exceeded |
60 |
Execution timed out |
1094 ms |
56796 KB |
Time limit exceeded |
61 |
Execution timed out |
1101 ms |
56724 KB |
Time limit exceeded |
62 |
Execution timed out |
1094 ms |
56768 KB |
Time limit exceeded |
63 |
Execution timed out |
1091 ms |
56740 KB |
Time limit exceeded |
64 |
Execution timed out |
1092 ms |
56780 KB |
Time limit exceeded |
65 |
Execution timed out |
1095 ms |
56816 KB |
Time limit exceeded |
66 |
Execution timed out |
1087 ms |
56812 KB |
Time limit exceeded |
67 |
Execution timed out |
1091 ms |
56308 KB |
Time limit exceeded |
68 |
Execution timed out |
1102 ms |
56556 KB |
Time limit exceeded |
69 |
Execution timed out |
1080 ms |
56300 KB |
Time limit exceeded |
70 |
Execution timed out |
1093 ms |
45676 KB |
Time limit exceeded |
71 |
Execution timed out |
1091 ms |
56556 KB |
Time limit exceeded |
72 |
Execution timed out |
1097 ms |
56428 KB |
Time limit exceeded |
73 |
Execution timed out |
1095 ms |
56684 KB |
Time limit exceeded |
74 |
Execution timed out |
1094 ms |
56684 KB |
Time limit exceeded |
75 |
Execution timed out |
1084 ms |
56684 KB |
Time limit exceeded |
76 |
Execution timed out |
1089 ms |
56684 KB |
Time limit exceeded |
77 |
Execution timed out |
1094 ms |
56556 KB |
Time limit exceeded |
78 |
Execution timed out |
1088 ms |
55928 KB |
Time limit exceeded |
79 |
Execution timed out |
1085 ms |
55560 KB |
Time limit exceeded |
80 |
Execution timed out |
1088 ms |
55404 KB |
Time limit exceeded |
81 |
Execution timed out |
1095 ms |
55408 KB |
Time limit exceeded |
82 |
Execution timed out |
1096 ms |
55404 KB |
Time limit exceeded |
83 |
Execution timed out |
1095 ms |
55404 KB |
Time limit exceeded |
84 |
Execution timed out |
1098 ms |
55528 KB |
Time limit exceeded |
85 |
Execution timed out |
1097 ms |
55532 KB |
Time limit exceeded |
86 |
Execution timed out |
1096 ms |
55532 KB |
Time limit exceeded |
87 |
Execution timed out |
1095 ms |
55532 KB |
Time limit exceeded |
88 |
Execution timed out |
1096 ms |
55436 KB |
Time limit exceeded |
89 |
Execution timed out |
1094 ms |
55532 KB |
Time limit exceeded |
90 |
Execution timed out |
1095 ms |
44396 KB |
Time limit exceeded |
91 |
Execution timed out |
1099 ms |
55532 KB |
Time limit exceeded |
92 |
Execution timed out |
1094 ms |
55532 KB |
Time limit exceeded |
93 |
Execution timed out |
1095 ms |
55532 KB |
Time limit exceeded |
94 |
Execution timed out |
1097 ms |
55532 KB |
Time limit exceeded |
95 |
Execution timed out |
1094 ms |
55404 KB |
Time limit exceeded |
96 |
Execution timed out |
1096 ms |
55532 KB |
Time limit exceeded |
97 |
Execution timed out |
1092 ms |
55532 KB |
Time limit exceeded |
98 |
Execution timed out |
1092 ms |
55404 KB |
Time limit exceeded |
99 |
Execution timed out |
1100 ms |
55532 KB |
Time limit exceeded |
100 |
Execution timed out |
1079 ms |
55532 KB |
Time limit exceeded |