# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
333933 |
2020-12-08T03:37:06 Z |
juggernaut |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
55704 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_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;
}
bool check(int x,int y){
if(n>m)return check_1(x,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];
}
int tl=1,tr=n;
while(tl<tr){
int tmid=(tl+tr+1)>>1;
int l=1,r=m;
while(l<r){
int mid=(l+r+1)>>1;
if(check(tmid,mid))l=mid;
else r=mid-1;
}
if(!check(tmid,l))l=0;
if(l)tl=tmid;
else tr=tmid-1;
}
int l=1,r=m;
while(l<r){
int mid=(l+r+1)>>1;
if(check(tl,mid))l=mid;
else r=mid-1;
}
printf("%d",tl*l);
}
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:49:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
49 | 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 |
26476 KB |
Output is correct |
4 |
Correct |
18 ms |
26476 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Incorrect |
1 ms |
492 KB |
Output isn't 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 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
16 |
Correct |
1 ms |
492 KB |
Output is correct |
17 |
Correct |
2 ms |
1004 KB |
Output is correct |
18 |
Incorrect |
2 ms |
1132 KB |
Output isn't correct |
19 |
Incorrect |
2 ms |
1388 KB |
Output isn't correct |
20 |
Incorrect |
2 ms |
1388 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
896 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
1132 KB |
Output isn't correct |
23 |
Incorrect |
3 ms |
1516 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
1260 KB |
Output isn't correct |
25 |
Incorrect |
3 ms |
1516 KB |
Output isn't correct |
26 |
Correct |
8 ms |
1516 KB |
Output is correct |
27 |
Correct |
61 ms |
4204 KB |
Output is correct |
28 |
Incorrect |
25 ms |
4204 KB |
Output isn't correct |
29 |
Incorrect |
185 ms |
5376 KB |
Output isn't correct |
30 |
Incorrect |
73 ms |
6380 KB |
Output isn't correct |
31 |
Incorrect |
42 ms |
4992 KB |
Output isn't correct |
32 |
Incorrect |
36 ms |
5844 KB |
Output isn't correct |
33 |
Incorrect |
154 ms |
6764 KB |
Output isn't correct |
34 |
Incorrect |
21 ms |
4716 KB |
Output isn't correct |
35 |
Incorrect |
49 ms |
6764 KB |
Output isn't correct |
36 |
Execution timed out |
1044 ms |
6636 KB |
Time limit exceeded |
37 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
38 |
Execution timed out |
1094 ms |
55444 KB |
Time limit exceeded |
39 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
40 |
Execution timed out |
1097 ms |
15596 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
492 KB |
Output is correct |
42 |
Incorrect |
6 ms |
1516 KB |
Output isn't correct |
43 |
Execution timed out |
1085 ms |
55532 KB |
Time limit exceeded |
44 |
Incorrect |
765 ms |
6764 KB |
Output isn't correct |
45 |
Execution timed out |
1096 ms |
55532 KB |
Time limit exceeded |
46 |
Execution timed out |
1094 ms |
55544 KB |
Time limit exceeded |
47 |
Execution timed out |
1047 ms |
55532 KB |
Time limit exceeded |
48 |
Execution timed out |
1050 ms |
55532 KB |
Time limit exceeded |
49 |
Execution timed out |
1080 ms |
55404 KB |
Time limit exceeded |
50 |
Execution timed out |
1086 ms |
55404 KB |
Time limit exceeded |
51 |
Execution timed out |
1087 ms |
55532 KB |
Time limit exceeded |
52 |
Execution timed out |
1095 ms |
55532 KB |
Time limit exceeded |
53 |
Execution timed out |
1054 ms |
55660 KB |
Time limit exceeded |
54 |
Execution timed out |
1097 ms |
55532 KB |
Time limit exceeded |
55 |
Execution timed out |
1092 ms |
55532 KB |
Time limit exceeded |
56 |
Execution timed out |
1050 ms |
55640 KB |
Time limit exceeded |
57 |
Execution timed out |
1101 ms |
55532 KB |
Time limit exceeded |
58 |
Execution timed out |
1098 ms |
55532 KB |
Time limit exceeded |
59 |
Execution timed out |
1093 ms |
55404 KB |
Time limit exceeded |
60 |
Execution timed out |
1088 ms |
55532 KB |
Time limit exceeded |
61 |
Execution timed out |
1084 ms |
55532 KB |
Time limit exceeded |
62 |
Execution timed out |
1097 ms |
55404 KB |
Time limit exceeded |
63 |
Execution timed out |
1099 ms |
55532 KB |
Time limit exceeded |
64 |
Execution timed out |
1055 ms |
55532 KB |
Time limit exceeded |
65 |
Execution timed out |
1100 ms |
55404 KB |
Time limit exceeded |
66 |
Execution timed out |
1064 ms |
55532 KB |
Time limit exceeded |
67 |
Execution timed out |
1062 ms |
55704 KB |
Time limit exceeded |
68 |
Execution timed out |
1096 ms |
55404 KB |
Time limit exceeded |
69 |
Execution timed out |
1055 ms |
55404 KB |
Time limit exceeded |
70 |
Execution timed out |
1092 ms |
44396 KB |
Time limit exceeded |
71 |
Execution timed out |
1060 ms |
55532 KB |
Time limit exceeded |
72 |
Execution timed out |
1071 ms |
55404 KB |
Time limit exceeded |
73 |
Execution timed out |
1051 ms |
55404 KB |
Time limit exceeded |
74 |
Execution timed out |
1070 ms |
55404 KB |
Time limit exceeded |
75 |
Execution timed out |
1103 ms |
55404 KB |
Time limit exceeded |
76 |
Execution timed out |
1103 ms |
55532 KB |
Time limit exceeded |
77 |
Execution timed out |
1074 ms |
55404 KB |
Time limit exceeded |
78 |
Execution timed out |
1095 ms |
55404 KB |
Time limit exceeded |
79 |
Execution timed out |
1045 ms |
55404 KB |
Time limit exceeded |
80 |
Execution timed out |
1093 ms |
55660 KB |
Time limit exceeded |
81 |
Execution timed out |
1077 ms |
55540 KB |
Time limit exceeded |
82 |
Execution timed out |
1101 ms |
55404 KB |
Time limit exceeded |
83 |
Execution timed out |
1102 ms |
55404 KB |
Time limit exceeded |
84 |
Execution timed out |
1063 ms |
55404 KB |
Time limit exceeded |
85 |
Execution timed out |
1075 ms |
55660 KB |
Time limit exceeded |
86 |
Execution timed out |
1103 ms |
55404 KB |
Time limit exceeded |
87 |
Execution timed out |
1090 ms |
55404 KB |
Time limit exceeded |
88 |
Execution timed out |
1100 ms |
55532 KB |
Time limit exceeded |
89 |
Execution timed out |
1099 ms |
55404 KB |
Time limit exceeded |
90 |
Execution timed out |
1042 ms |
44524 KB |
Time limit exceeded |
91 |
Execution timed out |
1085 ms |
55404 KB |
Time limit exceeded |
92 |
Execution timed out |
1089 ms |
55404 KB |
Time limit exceeded |
93 |
Execution timed out |
1101 ms |
55532 KB |
Time limit exceeded |
94 |
Execution timed out |
1089 ms |
55532 KB |
Time limit exceeded |
95 |
Execution timed out |
1051 ms |
55532 KB |
Time limit exceeded |
96 |
Execution timed out |
1097 ms |
55404 KB |
Time limit exceeded |
97 |
Execution timed out |
1097 ms |
55496 KB |
Time limit exceeded |
98 |
Execution timed out |
1039 ms |
55532 KB |
Time limit exceeded |
99 |
Execution timed out |
1100 ms |
55404 KB |
Time limit exceeded |
100 |
Execution timed out |
1095 ms |
55404 KB |
Time limit exceeded |