# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
334542 |
2020-12-09T11:17:34 Z |
beksultan04 |
Bomb (IZhO17_bomb) |
C++14 |
|
457 ms |
78060 KB |
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e5+12,INF=1e9+7;
int q[2505][2505],dp[N],up[2505][2505],down[2505][2505],ans[N];
main(){
int n,m,i,j,X=INF,Y=INF;
cin>>n>>m;
for (i=1;i<=n;++i)
for (j=1;j<=m;++j){
char ch;
cin>>ch;
q[i][j]=ch-'0';
}
for (i=1;i<=n;++i){
for (j=1;j<=m;++j){
if (q[i][j]){
up[i][j] = 1+up[i-1][j];
}
}
}
for (i=n;i>0;--i){
for (j=1;j<=m;++j){
if (q[i][j]){
down[i][j] = 1+down[i+1][j];
if (q[i-1][j] == 0)X = min(X,down[i][j]);
}
}
}
/// /// /// ///
for (i=1;i<=m;++i){
ans[i]=X;
}
for (i=1;i<=n;++i){
int a=INF,b=INF,c=0;
for (j=1;j<=m;++j){
if (q[i][j] == 0){
if (c != 0)
X = min(X,c);
a=b=INF;
c=0;
}
else {
a = min(a,down[i][j]);
b = min(b,up[i][j]);
c++;
ans[c] = min(ans[c],b+a-1);
}
}
a=INF,b=INF,c=0;
for (j=m;j>0;--j){
if (q[i][j] == 0){
if (c != 0)
Y = min(Y,c);
a=b=INF;
c=0;
}
else {
a = min(a,down[i][j]);
b = min(b,up[i][j]);
c++;
ans[c] = min(ans[c],b+a-1);
}
}
if (c > 0)
Y = min(Y,c);
}
/// /// /// ///
int mx = 0;
for (i=1;i<=Y;++i){
mx = max(mx,ans[i]*i);
}
cout <<mx;
}
Compilation message
bomb.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
18 | main(){
| ^
# |
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 |
16 ms |
30444 KB |
Output is correct |
4 |
Correct |
17 ms |
30444 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 |
620 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 |
620 KB |
Output is correct |
17 |
Correct |
1 ms |
1132 KB |
Output is correct |
18 |
Correct |
1 ms |
896 KB |
Output is correct |
19 |
Correct |
1 ms |
1132 KB |
Output is correct |
20 |
Correct |
1 ms |
1132 KB |
Output is correct |
21 |
Correct |
1 ms |
748 KB |
Output is correct |
22 |
Correct |
1 ms |
1004 KB |
Output is correct |
23 |
Correct |
2 ms |
1260 KB |
Output is correct |
24 |
Correct |
1 ms |
1132 KB |
Output is correct |
25 |
Correct |
2 ms |
1516 KB |
Output is correct |
26 |
Correct |
2 ms |
1644 KB |
Output is correct |
27 |
Correct |
8 ms |
4844 KB |
Output is correct |
28 |
Correct |
11 ms |
2284 KB |
Output is correct |
29 |
Correct |
12 ms |
6252 KB |
Output is correct |
30 |
Correct |
15 ms |
5612 KB |
Output is correct |
31 |
Correct |
12 ms |
4204 KB |
Output is correct |
32 |
Correct |
13 ms |
5356 KB |
Output is correct |
33 |
Correct |
17 ms |
6764 KB |
Output is correct |
34 |
Correct |
7 ms |
2540 KB |
Output is correct |
35 |
Correct |
15 ms |
3436 KB |
Output is correct |
36 |
Correct |
18 ms |
8044 KB |
Output is correct |
37 |
Correct |
1 ms |
512 KB |
Output is correct |
38 |
Correct |
450 ms |
78060 KB |
Output is correct |
39 |
Correct |
1 ms |
620 KB |
Output is correct |
40 |
Correct |
62 ms |
19920 KB |
Output is correct |
41 |
Correct |
1 ms |
620 KB |
Output is correct |
42 |
Correct |
2 ms |
1644 KB |
Output is correct |
43 |
Correct |
440 ms |
70120 KB |
Output is correct |
44 |
Correct |
18 ms |
7660 KB |
Output is correct |
45 |
Correct |
447 ms |
71404 KB |
Output is correct |
46 |
Correct |
447 ms |
78060 KB |
Output is correct |
47 |
Correct |
437 ms |
71532 KB |
Output is correct |
48 |
Correct |
440 ms |
77420 KB |
Output is correct |
49 |
Correct |
451 ms |
78060 KB |
Output is correct |
50 |
Correct |
457 ms |
77920 KB |
Output is correct |
51 |
Correct |
450 ms |
73964 KB |
Output is correct |
52 |
Correct |
440 ms |
74348 KB |
Output is correct |
53 |
Correct |
438 ms |
73196 KB |
Output is correct |
54 |
Correct |
428 ms |
60524 KB |
Output is correct |
55 |
Correct |
427 ms |
58868 KB |
Output is correct |
56 |
Correct |
451 ms |
77932 KB |
Output is correct |
57 |
Correct |
422 ms |
53868 KB |
Output is correct |
58 |
Correct |
430 ms |
59084 KB |
Output is correct |
59 |
Correct |
421 ms |
55788 KB |
Output is correct |
60 |
Correct |
434 ms |
65772 KB |
Output is correct |
61 |
Correct |
446 ms |
78060 KB |
Output is correct |
62 |
Correct |
444 ms |
77932 KB |
Output is correct |
63 |
Correct |
446 ms |
78060 KB |
Output is correct |
64 |
Correct |
426 ms |
57068 KB |
Output is correct |
65 |
Correct |
435 ms |
72940 KB |
Output is correct |
66 |
Correct |
435 ms |
69740 KB |
Output is correct |
67 |
Correct |
442 ms |
77932 KB |
Output is correct |
68 |
Correct |
442 ms |
78060 KB |
Output is correct |
69 |
Correct |
425 ms |
53484 KB |
Output is correct |
70 |
Correct |
264 ms |
29932 KB |
Output is correct |
71 |
Correct |
420 ms |
46444 KB |
Output is correct |
72 |
Correct |
426 ms |
51948 KB |
Output is correct |
73 |
Correct |
422 ms |
52460 KB |
Output is correct |
74 |
Correct |
434 ms |
53980 KB |
Output is correct |
75 |
Correct |
426 ms |
55532 KB |
Output is correct |
76 |
Correct |
428 ms |
56940 KB |
Output is correct |
77 |
Correct |
421 ms |
57452 KB |
Output is correct |
78 |
Correct |
427 ms |
57708 KB |
Output is correct |
79 |
Correct |
420 ms |
30188 KB |
Output is correct |
80 |
Correct |
420 ms |
31492 KB |
Output is correct |
81 |
Correct |
410 ms |
31756 KB |
Output is correct |
82 |
Correct |
426 ms |
60140 KB |
Output is correct |
83 |
Correct |
430 ms |
60316 KB |
Output is correct |
84 |
Correct |
415 ms |
25452 KB |
Output is correct |
85 |
Correct |
432 ms |
59244 KB |
Output is correct |
86 |
Correct |
453 ms |
76784 KB |
Output is correct |
87 |
Correct |
428 ms |
58164 KB |
Output is correct |
88 |
Correct |
428 ms |
58988 KB |
Output is correct |
89 |
Correct |
449 ms |
67760 KB |
Output is correct |
90 |
Correct |
292 ms |
44124 KB |
Output is correct |
91 |
Correct |
433 ms |
62948 KB |
Output is correct |
92 |
Correct |
433 ms |
64628 KB |
Output is correct |
93 |
Correct |
445 ms |
75656 KB |
Output is correct |
94 |
Correct |
432 ms |
66540 KB |
Output is correct |
95 |
Correct |
446 ms |
60396 KB |
Output is correct |
96 |
Correct |
424 ms |
60012 KB |
Output is correct |
97 |
Correct |
442 ms |
76540 KB |
Output is correct |
98 |
Correct |
425 ms |
59932 KB |
Output is correct |
99 |
Correct |
443 ms |
66156 KB |
Output is correct |
100 |
Correct |
440 ms |
75244 KB |
Output is correct |