# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
334197 |
2020-12-08T15:37:12 Z |
juggernaut |
Bomb (IZhO17_bomb) |
C++14 |
|
355 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>2000){
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 |
11 ms |
16492 KB |
Output isn't correct |
4 |
Incorrect |
12 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 |
620 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
636 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 |
Incorrect |
3 ms |
1388 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
1388 KB |
Output isn't correct |
21 |
Correct |
2 ms |
876 KB |
Output is correct |
22 |
Incorrect |
3 ms |
1132 KB |
Output isn't correct |
23 |
Incorrect |
3 ms |
1516 KB |
Output isn't correct |
24 |
Correct |
3 ms |
1260 KB |
Output is correct |
25 |
Incorrect |
3 ms |
1516 KB |
Output isn't correct |
26 |
Incorrect |
3 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 |
9 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 |
13 ms |
4076 KB |
Output isn't correct |
34 |
Incorrect |
6 ms |
2924 KB |
Output isn't correct |
35 |
Incorrect |
12 ms |
4076 KB |
Output isn't correct |
36 |
Incorrect |
13 ms |
4076 KB |
Output isn't correct |
37 |
Correct |
1 ms |
492 KB |
Output is correct |
38 |
Incorrect |
350 ms |
30908 KB |
Output isn't correct |
39 |
Correct |
1 ms |
492 KB |
Output is correct |
40 |
Incorrect |
45 ms |
9068 KB |
Output isn't correct |
41 |
Correct |
1 ms |
492 KB |
Output is correct |
42 |
Incorrect |
3 ms |
1516 KB |
Output isn't correct |
43 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
44 |
Incorrect |
12 ms |
4076 KB |
Output isn't correct |
45 |
Incorrect |
325 ms |
30956 KB |
Output isn't correct |
46 |
Incorrect |
308 ms |
30956 KB |
Output isn't correct |
47 |
Incorrect |
307 ms |
30956 KB |
Output isn't correct |
48 |
Incorrect |
318 ms |
31084 KB |
Output isn't correct |
49 |
Incorrect |
318 ms |
31084 KB |
Output isn't correct |
50 |
Incorrect |
308 ms |
30956 KB |
Output isn't correct |
51 |
Incorrect |
349 ms |
30988 KB |
Output isn't correct |
52 |
Incorrect |
317 ms |
30956 KB |
Output isn't correct |
53 |
Incorrect |
322 ms |
31084 KB |
Output isn't correct |
54 |
Incorrect |
308 ms |
30956 KB |
Output isn't correct |
55 |
Incorrect |
310 ms |
31196 KB |
Output isn't correct |
56 |
Incorrect |
343 ms |
30956 KB |
Output isn't correct |
57 |
Incorrect |
310 ms |
31084 KB |
Output isn't correct |
58 |
Incorrect |
309 ms |
30956 KB |
Output isn't correct |
59 |
Incorrect |
309 ms |
30956 KB |
Output isn't correct |
60 |
Incorrect |
311 ms |
30956 KB |
Output isn't correct |
61 |
Incorrect |
316 ms |
30956 KB |
Output isn't correct |
62 |
Incorrect |
306 ms |
30956 KB |
Output isn't correct |
63 |
Incorrect |
318 ms |
31084 KB |
Output isn't correct |
64 |
Incorrect |
312 ms |
31084 KB |
Output isn't correct |
65 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
66 |
Incorrect |
321 ms |
31084 KB |
Output isn't correct |
67 |
Incorrect |
312 ms |
31184 KB |
Output isn't correct |
68 |
Incorrect |
355 ms |
31156 KB |
Output isn't correct |
69 |
Incorrect |
312 ms |
30956 KB |
Output isn't correct |
70 |
Incorrect |
207 ms |
24940 KB |
Output isn't correct |
71 |
Incorrect |
310 ms |
31084 KB |
Output isn't correct |
72 |
Incorrect |
314 ms |
30956 KB |
Output isn't correct |
73 |
Incorrect |
319 ms |
31084 KB |
Output isn't correct |
74 |
Incorrect |
309 ms |
31084 KB |
Output isn't correct |
75 |
Incorrect |
312 ms |
30956 KB |
Output isn't correct |
76 |
Incorrect |
308 ms |
31084 KB |
Output isn't correct |
77 |
Incorrect |
307 ms |
30956 KB |
Output isn't correct |
78 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
79 |
Incorrect |
306 ms |
30956 KB |
Output isn't correct |
80 |
Incorrect |
308 ms |
31084 KB |
Output isn't correct |
81 |
Incorrect |
317 ms |
30956 KB |
Output isn't correct |
82 |
Incorrect |
313 ms |
31084 KB |
Output isn't correct |
83 |
Incorrect |
333 ms |
30956 KB |
Output isn't correct |
84 |
Incorrect |
307 ms |
30956 KB |
Output isn't correct |
85 |
Incorrect |
313 ms |
31084 KB |
Output isn't correct |
86 |
Incorrect |
309 ms |
30956 KB |
Output isn't correct |
87 |
Incorrect |
308 ms |
31084 KB |
Output isn't correct |
88 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
89 |
Incorrect |
310 ms |
31212 KB |
Output isn't correct |
90 |
Incorrect |
200 ms |
24812 KB |
Output isn't correct |
91 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
92 |
Incorrect |
311 ms |
31084 KB |
Output isn't correct |
93 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
94 |
Incorrect |
307 ms |
31084 KB |
Output isn't correct |
95 |
Incorrect |
306 ms |
30944 KB |
Output isn't correct |
96 |
Incorrect |
312 ms |
31084 KB |
Output isn't correct |
97 |
Incorrect |
312 ms |
30956 KB |
Output isn't correct |
98 |
Incorrect |
310 ms |
30956 KB |
Output isn't correct |
99 |
Incorrect |
307 ms |
31084 KB |
Output isn't correct |
100 |
Incorrect |
307 ms |
30956 KB |
Output isn't correct |