# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
334194 |
2020-12-08T15:33:32 Z |
juggernaut |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
55744 KB |
#include<bits/stdc++.h>
using namespace std;
int n,m,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));
}
void add(int x,int y,int x2,int y2){
x2++,y2++;
pref[x][y]++;
pref[x2][y2]++;
pref[x][y2]--;
pref[x2][y]--;
}
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))
add(i,j,i+x-1,j+y-1);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
pref[i][j]=pref[i][j]-pref[i-1][j-1]+pref[i][j-1]+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];
}
int y=1,x=n;
int mx=0;
for(;y<=m;y++){
while(x&&!check(x,y))x--;
mx=max(mx,x*y);
}
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:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
37 | 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 |
153 ms |
26604 KB |
Output is correct |
4 |
Correct |
142 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 |
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 |
2 ms |
1004 KB |
Output is correct |
18 |
Correct |
2 ms |
1132 KB |
Output is correct |
19 |
Correct |
4 ms |
1388 KB |
Output is correct |
20 |
Correct |
4 ms |
1388 KB |
Output is correct |
21 |
Correct |
2 ms |
876 KB |
Output is correct |
22 |
Correct |
2 ms |
1132 KB |
Output is correct |
23 |
Correct |
5 ms |
1516 KB |
Output is correct |
24 |
Correct |
3 ms |
1260 KB |
Output is correct |
25 |
Correct |
6 ms |
1516 KB |
Output is correct |
26 |
Correct |
4 ms |
1516 KB |
Output is correct |
27 |
Correct |
57 ms |
4204 KB |
Output is correct |
28 |
Correct |
58 ms |
4204 KB |
Output is correct |
29 |
Correct |
155 ms |
5460 KB |
Output is correct |
30 |
Correct |
297 ms |
6380 KB |
Output is correct |
31 |
Correct |
186 ms |
4972 KB |
Output is correct |
32 |
Correct |
173 ms |
5868 KB |
Output is correct |
33 |
Correct |
350 ms |
6764 KB |
Output is correct |
34 |
Correct |
56 ms |
4716 KB |
Output is correct |
35 |
Correct |
320 ms |
6784 KB |
Output is correct |
36 |
Correct |
224 ms |
6636 KB |
Output is correct |
37 |
Correct |
1 ms |
492 KB |
Output is correct |
38 |
Execution timed out |
1070 ms |
55572 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
512 KB |
Output is correct |
40 |
Execution timed out |
1086 ms |
15724 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
492 KB |
Output is correct |
42 |
Correct |
6 ms |
1516 KB |
Output is correct |
43 |
Execution timed out |
1088 ms |
55532 KB |
Time limit exceeded |
44 |
Correct |
437 ms |
6636 KB |
Output is correct |
45 |
Execution timed out |
1088 ms |
55532 KB |
Time limit exceeded |
46 |
Execution timed out |
1072 ms |
55516 KB |
Time limit exceeded |
47 |
Execution timed out |
1083 ms |
55532 KB |
Time limit exceeded |
48 |
Execution timed out |
1088 ms |
55660 KB |
Time limit exceeded |
49 |
Execution timed out |
1042 ms |
55532 KB |
Time limit exceeded |
50 |
Execution timed out |
1087 ms |
55532 KB |
Time limit exceeded |
51 |
Execution timed out |
1092 ms |
55532 KB |
Time limit exceeded |
52 |
Execution timed out |
1094 ms |
55532 KB |
Time limit exceeded |
53 |
Execution timed out |
1061 ms |
55532 KB |
Time limit exceeded |
54 |
Execution timed out |
1093 ms |
55404 KB |
Time limit exceeded |
55 |
Execution timed out |
1071 ms |
55532 KB |
Time limit exceeded |
56 |
Execution timed out |
1054 ms |
55660 KB |
Time limit exceeded |
57 |
Execution timed out |
1089 ms |
55404 KB |
Time limit exceeded |
58 |
Execution timed out |
1096 ms |
55404 KB |
Time limit exceeded |
59 |
Execution timed out |
1095 ms |
55404 KB |
Time limit exceeded |
60 |
Execution timed out |
1086 ms |
55532 KB |
Time limit exceeded |
61 |
Execution timed out |
1083 ms |
55532 KB |
Time limit exceeded |
62 |
Execution timed out |
1097 ms |
55532 KB |
Time limit exceeded |
63 |
Execution timed out |
1096 ms |
55532 KB |
Time limit exceeded |
64 |
Execution timed out |
1074 ms |
55532 KB |
Time limit exceeded |
65 |
Execution timed out |
1056 ms |
55532 KB |
Time limit exceeded |
66 |
Execution timed out |
1082 ms |
55532 KB |
Time limit exceeded |
67 |
Execution timed out |
1092 ms |
55532 KB |
Time limit exceeded |
68 |
Execution timed out |
1083 ms |
55532 KB |
Time limit exceeded |
69 |
Execution timed out |
1092 ms |
55404 KB |
Time limit exceeded |
70 |
Execution timed out |
1048 ms |
44396 KB |
Time limit exceeded |
71 |
Execution timed out |
1067 ms |
55680 KB |
Time limit exceeded |
72 |
Execution timed out |
1068 ms |
55532 KB |
Time limit exceeded |
73 |
Execution timed out |
1055 ms |
55692 KB |
Time limit exceeded |
74 |
Execution timed out |
1094 ms |
55404 KB |
Time limit exceeded |
75 |
Execution timed out |
1096 ms |
55404 KB |
Time limit exceeded |
76 |
Execution timed out |
1098 ms |
55532 KB |
Time limit exceeded |
77 |
Execution timed out |
1103 ms |
55404 KB |
Time limit exceeded |
78 |
Execution timed out |
1102 ms |
55532 KB |
Time limit exceeded |
79 |
Execution timed out |
1095 ms |
55404 KB |
Time limit exceeded |
80 |
Execution timed out |
1100 ms |
55404 KB |
Time limit exceeded |
81 |
Execution timed out |
1040 ms |
55532 KB |
Time limit exceeded |
82 |
Execution timed out |
1058 ms |
55556 KB |
Time limit exceeded |
83 |
Execution timed out |
1093 ms |
55636 KB |
Time limit exceeded |
84 |
Execution timed out |
1096 ms |
55404 KB |
Time limit exceeded |
85 |
Execution timed out |
1058 ms |
55532 KB |
Time limit exceeded |
86 |
Execution timed out |
1091 ms |
55532 KB |
Time limit exceeded |
87 |
Execution timed out |
1099 ms |
55404 KB |
Time limit exceeded |
88 |
Execution timed out |
1085 ms |
55660 KB |
Time limit exceeded |
89 |
Execution timed out |
1094 ms |
55404 KB |
Time limit exceeded |
90 |
Execution timed out |
1101 ms |
44396 KB |
Time limit exceeded |
91 |
Execution timed out |
1095 ms |
55532 KB |
Time limit exceeded |
92 |
Execution timed out |
1055 ms |
55532 KB |
Time limit exceeded |
93 |
Execution timed out |
1099 ms |
55404 KB |
Time limit exceeded |
94 |
Execution timed out |
1097 ms |
55404 KB |
Time limit exceeded |
95 |
Execution timed out |
1096 ms |
55404 KB |
Time limit exceeded |
96 |
Execution timed out |
1097 ms |
55404 KB |
Time limit exceeded |
97 |
Execution timed out |
1089 ms |
55744 KB |
Time limit exceeded |
98 |
Execution timed out |
1095 ms |
55404 KB |
Time limit exceeded |
99 |
Execution timed out |
1092 ms |
55532 KB |
Time limit exceeded |
100 |
Execution timed out |
1097 ms |
55660 KB |
Time limit exceeded |