# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
37227 |
2017-12-22T17:50:52 Z |
alenam0161 |
Bomb (IZhO17_bomb) |
C++14 |
|
889 ms |
63304 KB |
#include<bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
char c1[2505][2505],c2[2505][2505];
int n,m,l,r,bolo;
int lf[2505][2505],rg[2505][ 2505],zr[2505];
pair<int, int> ans;
int main(){
// freopen("bomb.in","r",stdin);
// freopen("bomb.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i) scanf("%s", &c1[i][1]);
for(int i=0;i<2505;++i) zr[i] = inf;
for(int i=0;i<2;++i) {
memset((lf), 0, sizeof(lf));
memset((rg), 0, sizeof(rg));
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j)
if(c1[i][j] == '1') lf[i][j] = lf[i][j-1] + 1;
for(int j=m;j>=1;--j)
if(c1[i][j] == '1') rg[i][j] = rg[i][j+1] + 1;
for(int j=1;j<=m;++j)
if(c1[i][j] == '1' && c1[i][j+1] != '1') zr[1] = min(zr[1], lf[i][j]);
}
for(int j=1;j<=m;++j)
for(int i=0;i<=n+1;++i)
if(c1[i][j] == '1') {
l = min(l, lf[i][j]); r = min(r, rg[i][j]);
zr[i - bolo] = min(zr[i - bolo], l + r - 1);
} else {
if(i && bolo != i-1) zr[i - bolo] = 0;
l = inf; r = inf; bolo = i;
}
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
c2[i][j] = c1[n+1-i][j];
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
c1[i][j] = c2[i][j];
}
int b = inf;
for(int a=1;a<=2504;++a) {
b = min(b, zr[a]);
ans = max(ans, {a*b, b});
}
cout << ans.first<< endl;
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:12:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
bomb.cpp:13:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(int i=1;i<=n;++i) scanf("%s", &c1[i][1]);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
63304 KB |
Output is correct |
2 |
Correct |
16 ms |
63304 KB |
Output is correct |
3 |
Correct |
16 ms |
63304 KB |
Output is correct |
4 |
Correct |
19 ms |
63304 KB |
Output is correct |
5 |
Correct |
23 ms |
63304 KB |
Output is correct |
6 |
Correct |
13 ms |
63304 KB |
Output is correct |
7 |
Correct |
16 ms |
63304 KB |
Output is correct |
8 |
Correct |
23 ms |
63304 KB |
Output is correct |
9 |
Correct |
16 ms |
63304 KB |
Output is correct |
10 |
Correct |
19 ms |
63304 KB |
Output is correct |
11 |
Correct |
19 ms |
63304 KB |
Output is correct |
12 |
Correct |
19 ms |
63304 KB |
Output is correct |
13 |
Correct |
16 ms |
63304 KB |
Output is correct |
14 |
Correct |
19 ms |
63304 KB |
Output is correct |
15 |
Correct |
19 ms |
63304 KB |
Output is correct |
16 |
Correct |
16 ms |
63304 KB |
Output is correct |
17 |
Correct |
16 ms |
63304 KB |
Output is correct |
18 |
Correct |
16 ms |
63304 KB |
Output is correct |
19 |
Correct |
16 ms |
63304 KB |
Output is correct |
20 |
Correct |
16 ms |
63304 KB |
Output is correct |
21 |
Correct |
23 ms |
63304 KB |
Output is correct |
22 |
Correct |
19 ms |
63304 KB |
Output is correct |
23 |
Correct |
16 ms |
63304 KB |
Output is correct |
24 |
Correct |
19 ms |
63304 KB |
Output is correct |
25 |
Correct |
16 ms |
63304 KB |
Output is correct |
26 |
Correct |
19 ms |
63304 KB |
Output is correct |
27 |
Correct |
19 ms |
63304 KB |
Output is correct |
28 |
Correct |
16 ms |
63304 KB |
Output is correct |
29 |
Correct |
19 ms |
63304 KB |
Output is correct |
30 |
Correct |
26 ms |
63304 KB |
Output is correct |
31 |
Correct |
19 ms |
63304 KB |
Output is correct |
32 |
Correct |
13 ms |
63304 KB |
Output is correct |
33 |
Correct |
26 ms |
63304 KB |
Output is correct |
34 |
Correct |
16 ms |
63304 KB |
Output is correct |
35 |
Correct |
19 ms |
63304 KB |
Output is correct |
36 |
Correct |
23 ms |
63304 KB |
Output is correct |
37 |
Correct |
16 ms |
63304 KB |
Output is correct |
38 |
Correct |
866 ms |
63304 KB |
Output is correct |
39 |
Correct |
19 ms |
63304 KB |
Output is correct |
40 |
Correct |
83 ms |
63304 KB |
Output is correct |
41 |
Correct |
19 ms |
63304 KB |
Output is correct |
42 |
Correct |
19 ms |
63304 KB |
Output is correct |
43 |
Correct |
629 ms |
63304 KB |
Output is correct |
44 |
Correct |
16 ms |
63304 KB |
Output is correct |
45 |
Correct |
623 ms |
63304 KB |
Output is correct |
46 |
Correct |
593 ms |
63304 KB |
Output is correct |
47 |
Correct |
613 ms |
63304 KB |
Output is correct |
48 |
Correct |
529 ms |
63304 KB |
Output is correct |
49 |
Correct |
849 ms |
63304 KB |
Output is correct |
50 |
Correct |
606 ms |
63304 KB |
Output is correct |
51 |
Correct |
553 ms |
63304 KB |
Output is correct |
52 |
Correct |
559 ms |
63304 KB |
Output is correct |
53 |
Correct |
593 ms |
63304 KB |
Output is correct |
54 |
Correct |
429 ms |
63304 KB |
Output is correct |
55 |
Correct |
379 ms |
63304 KB |
Output is correct |
56 |
Correct |
889 ms |
63304 KB |
Output is correct |
57 |
Correct |
386 ms |
63304 KB |
Output is correct |
58 |
Correct |
409 ms |
63304 KB |
Output is correct |
59 |
Correct |
409 ms |
63304 KB |
Output is correct |
60 |
Correct |
526 ms |
63304 KB |
Output is correct |
61 |
Correct |
869 ms |
63304 KB |
Output is correct |
62 |
Correct |
863 ms |
63304 KB |
Output is correct |
63 |
Correct |
866 ms |
63304 KB |
Output is correct |
64 |
Correct |
349 ms |
63304 KB |
Output is correct |
65 |
Correct |
556 ms |
63304 KB |
Output is correct |
66 |
Correct |
539 ms |
63304 KB |
Output is correct |
67 |
Correct |
579 ms |
63304 KB |
Output is correct |
68 |
Correct |
646 ms |
63304 KB |
Output is correct |
69 |
Correct |
359 ms |
63304 KB |
Output is correct |
70 |
Correct |
149 ms |
63304 KB |
Output is correct |
71 |
Correct |
273 ms |
63304 KB |
Output is correct |
72 |
Correct |
313 ms |
63304 KB |
Output is correct |
73 |
Correct |
326 ms |
63304 KB |
Output is correct |
74 |
Correct |
319 ms |
63304 KB |
Output is correct |
75 |
Correct |
319 ms |
63304 KB |
Output is correct |
76 |
Correct |
329 ms |
63304 KB |
Output is correct |
77 |
Correct |
416 ms |
63304 KB |
Output is correct |
78 |
Correct |
359 ms |
63304 KB |
Output is correct |
79 |
Correct |
143 ms |
63304 KB |
Output is correct |
80 |
Correct |
146 ms |
63304 KB |
Output is correct |
81 |
Correct |
183 ms |
63304 KB |
Output is correct |
82 |
Correct |
376 ms |
63304 KB |
Output is correct |
83 |
Correct |
386 ms |
63304 KB |
Output is correct |
84 |
Correct |
159 ms |
63304 KB |
Output is correct |
85 |
Correct |
333 ms |
63304 KB |
Output is correct |
86 |
Correct |
773 ms |
63304 KB |
Output is correct |
87 |
Correct |
306 ms |
63304 KB |
Output is correct |
88 |
Correct |
379 ms |
63304 KB |
Output is correct |
89 |
Correct |
529 ms |
63304 KB |
Output is correct |
90 |
Correct |
186 ms |
63304 KB |
Output is correct |
91 |
Correct |
403 ms |
63304 KB |
Output is correct |
92 |
Correct |
506 ms |
63304 KB |
Output is correct |
93 |
Correct |
736 ms |
63304 KB |
Output is correct |
94 |
Correct |
483 ms |
63304 KB |
Output is correct |
95 |
Correct |
363 ms |
63304 KB |
Output is correct |
96 |
Correct |
393 ms |
63304 KB |
Output is correct |
97 |
Correct |
773 ms |
63304 KB |
Output is correct |
98 |
Correct |
393 ms |
63304 KB |
Output is correct |
99 |
Correct |
509 ms |
63304 KB |
Output is correct |
100 |
Correct |
786 ms |
63304 KB |
Output is correct |