# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
334196 |
2020-12-08T15:36:12 Z |
juggernaut |
Bomb (IZhO17_bomb) |
C++14 |
|
322 ms |
31212 KB |
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt[2505][2505],pref[2505][2505],mx;
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]--;
}
clock_t start;
bool check(int x,int y){
if(clock()-start>900){
printf("%d",mx);
exit(0);
}
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(){
start=clock();
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;
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:43:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
43 | 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 |
Incorrect |
10 ms |
16492 KB |
Output isn't correct |
4 |
Incorrect |
10 ms |
16492 KB |
Output isn't 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 |
Incorrect |
1 ms |
1004 KB |
Output isn't correct |
18 |
Incorrect |
1 ms |
1132 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
1388 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
1260 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
896 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
1132 KB |
Output isn't correct |
23 |
Incorrect |
2 ms |
1516 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
1260 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
1516 KB |
Output isn't correct |
26 |
Incorrect |
2 ms |
1516 KB |
Output isn't correct |
27 |
Incorrect |
6 ms |
2540 KB |
Output isn't correct |
28 |
Incorrect |
7 ms |
2668 KB |
Output isn't correct |
29 |
Incorrect |
8 ms |
3308 KB |
Output isn't correct |
30 |
Incorrect |
11 ms |
3820 KB |
Output isn't correct |
31 |
Incorrect |
9 ms |
3052 KB |
Output isn't correct |
32 |
Incorrect |
10 ms |
3564 KB |
Output isn't correct |
33 |
Incorrect |
12 ms |
4076 KB |
Output isn't correct |
34 |
Incorrect |
6 ms |
3052 KB |
Output isn't correct |
35 |
Incorrect |
12 ms |
4076 KB |
Output isn't correct |
36 |
Incorrect |
12 ms |
4076 KB |
Output isn't correct |
37 |
Correct |
1 ms |
492 KB |
Output is correct |
38 |
Incorrect |
308 ms |
31084 KB |
Output isn't correct |
39 |
Correct |
1 ms |
492 KB |
Output is correct |
40 |
Incorrect |
41 ms |
9068 KB |
Output isn't correct |
41 |
Correct |
1 ms |
492 KB |
Output is correct |
42 |
Incorrect |
2 ms |
1516 KB |
Output isn't correct |
43 |
Incorrect |
309 ms |
30956 KB |
Output isn't correct |
44 |
Incorrect |
12 ms |
4076 KB |
Output isn't correct |
45 |
Incorrect |
306 ms |
30956 KB |
Output isn't correct |
46 |
Incorrect |
322 ms |
30956 KB |
Output isn't correct |
47 |
Incorrect |
303 ms |
30956 KB |
Output isn't correct |
48 |
Incorrect |
306 ms |
30956 KB |
Output isn't correct |
49 |
Incorrect |
311 ms |
30956 KB |
Output isn't correct |
50 |
Incorrect |
305 ms |
30956 KB |
Output isn't correct |
51 |
Incorrect |
309 ms |
31212 KB |
Output isn't correct |
52 |
Incorrect |
309 ms |
30956 KB |
Output isn't correct |
53 |
Incorrect |
308 ms |
31084 KB |
Output isn't correct |
54 |
Incorrect |
306 ms |
30956 KB |
Output isn't correct |
55 |
Incorrect |
309 ms |
31212 KB |
Output isn't correct |
56 |
Incorrect |
304 ms |
30956 KB |
Output isn't correct |
57 |
Incorrect |
304 ms |
30956 KB |
Output isn't correct |
58 |
Incorrect |
309 ms |
31084 KB |
Output isn't correct |
59 |
Incorrect |
305 ms |
30956 KB |
Output isn't correct |
60 |
Incorrect |
311 ms |
31084 KB |
Output isn't correct |
61 |
Incorrect |
305 ms |
30956 KB |
Output isn't correct |
62 |
Incorrect |
304 ms |
31084 KB |
Output isn't correct |
63 |
Incorrect |
305 ms |
30956 KB |
Output isn't correct |
64 |
Incorrect |
311 ms |
30956 KB |
Output isn't correct |
65 |
Incorrect |
307 ms |
30956 KB |
Output isn't correct |
66 |
Incorrect |
308 ms |
30956 KB |
Output isn't correct |
67 |
Incorrect |
308 ms |
31084 KB |
Output isn't correct |
68 |
Incorrect |
320 ms |
30956 KB |
Output isn't correct |
69 |
Incorrect |
318 ms |
30956 KB |
Output isn't correct |
70 |
Incorrect |
201 ms |
24812 KB |
Output isn't correct |
71 |
Incorrect |
313 ms |
30956 KB |
Output isn't correct |
72 |
Incorrect |
317 ms |
31084 KB |
Output isn't correct |
73 |
Incorrect |
309 ms |
30956 KB |
Output isn't correct |
74 |
Incorrect |
317 ms |
30956 KB |
Output isn't correct |
75 |
Incorrect |
308 ms |
30956 KB |
Output isn't correct |
76 |
Incorrect |
310 ms |
30980 KB |
Output isn't correct |
77 |
Incorrect |
309 ms |
30956 KB |
Output isn't correct |
78 |
Incorrect |
311 ms |
30956 KB |
Output isn't correct |
79 |
Incorrect |
308 ms |
30956 KB |
Output isn't correct |
80 |
Incorrect |
308 ms |
31084 KB |
Output isn't correct |
81 |
Incorrect |
307 ms |
30956 KB |
Output isn't correct |
82 |
Incorrect |
311 ms |
31084 KB |
Output isn't correct |
83 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
84 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
85 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
86 |
Incorrect |
308 ms |
30956 KB |
Output isn't correct |
87 |
Incorrect |
309 ms |
31084 KB |
Output isn't correct |
88 |
Incorrect |
309 ms |
31084 KB |
Output isn't correct |
89 |
Incorrect |
322 ms |
31084 KB |
Output isn't correct |
90 |
Incorrect |
201 ms |
24812 KB |
Output isn't correct |
91 |
Incorrect |
308 ms |
30956 KB |
Output isn't correct |
92 |
Incorrect |
316 ms |
31152 KB |
Output isn't correct |
93 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
94 |
Incorrect |
316 ms |
30956 KB |
Output isn't correct |
95 |
Incorrect |
307 ms |
30940 KB |
Output isn't correct |
96 |
Incorrect |
312 ms |
30956 KB |
Output isn't correct |
97 |
Incorrect |
315 ms |
30956 KB |
Output isn't correct |
98 |
Incorrect |
306 ms |
30956 KB |
Output isn't correct |
99 |
Incorrect |
312 ms |
30956 KB |
Output isn't correct |
100 |
Incorrect |
308 ms |
30988 KB |
Output isn't correct |