# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
334226 |
2020-12-08T17:03:28 Z |
juggernaut |
Bomb (IZhO17_bomb) |
C++14 |
|
617 ms |
56172 KB |
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=2509;
char arr[N][N];
int up[N][N],down[N][N],ans[N];
int main(){
//~ freopen("file.in", "r", stdin);
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
scanf(" %c",&arr[i][j]);
int xx=n,yy=m;
for(int i=1;i<=n;i++){
int cnt=0;
for(int j=1;j<=m;j++){
if(arr[i][j]=='1')
cnt++;
else{
if(cnt)
umin(yy,cnt);
cnt=0;
}
}
if(cnt)
umin(yy,cnt);
}
for(int j=1;j<=m;j++){
int cnt=0;
for(int i=1;i<=n;i++){
if(arr[i][j]=='1')
up[i][j]=up[i-1][j]+1,cnt++;
else{
if(cnt)
umin(xx,cnt);
cnt=0;
}
}
if(cnt)
umin(xx,cnt);
for(int i=n;i>=1;i--)
if(arr[i][j]=='1')
down[i][j]=down[i+1][j]+1;
}
for(int i=1;i<=yy;i++)
ans[i]=xx;
for(int i=1;i<=n;i++){
int cnt=0;
int a=INF,b=INF;
for(int j=1;j<=m;j++){
if(arr[i][j]=='1'){
umin(a,up[i][j]);
umin(b,down[i][j]);
umin(ans[++cnt],a+b-1);
}
else
cnt=0,a=b=INF;
}
}
int res=ans[1];
for(int i=2;i<=yy;i++){
umin(ans[i],ans[i-1]);
umax(res,i*ans[i]);
}printf("%d\n",res);
return 0;
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
26 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
bomb.cpp:29:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
29 | scanf(" %c",&arr[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~~~
# |
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 |
13 ms |
26476 KB |
Output is correct |
4 |
Correct |
14 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 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
492 KB |
Output is correct |
12 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
13 |
Correct |
1 ms |
492 KB |
Output is correct |
14 |
Correct |
1 ms |
492 KB |
Output is correct |
15 |
Incorrect |
1 ms |
628 KB |
Output isn't correct |
16 |
Correct |
1 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
1004 KB |
Output is correct |
18 |
Correct |
1 ms |
748 KB |
Output is correct |
19 |
Incorrect |
1 ms |
1004 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
1004 KB |
Output isn't correct |
21 |
Correct |
1 ms |
620 KB |
Output is correct |
22 |
Correct |
1 ms |
876 KB |
Output is correct |
23 |
Incorrect |
3 ms |
1132 KB |
Output isn't correct |
24 |
Incorrect |
2 ms |
1004 KB |
Output isn't correct |
25 |
Incorrect |
2 ms |
1536 KB |
Output isn't correct |
26 |
Correct |
2 ms |
1516 KB |
Output is correct |
27 |
Correct |
8 ms |
4076 KB |
Output is correct |
28 |
Incorrect |
9 ms |
1516 KB |
Output isn't correct |
29 |
Incorrect |
12 ms |
5248 KB |
Output isn't correct |
30 |
Incorrect |
15 ms |
4332 KB |
Output isn't correct |
31 |
Correct |
12 ms |
3200 KB |
Output is correct |
32 |
Incorrect |
15 ms |
4204 KB |
Output isn't correct |
33 |
Incorrect |
16 ms |
5356 KB |
Output isn't correct |
34 |
Incorrect |
7 ms |
1772 KB |
Output isn't correct |
35 |
Incorrect |
14 ms |
2060 KB |
Output isn't correct |
36 |
Correct |
19 ms |
6784 KB |
Output is correct |
37 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
38 |
Correct |
617 ms |
56172 KB |
Output is correct |
39 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
40 |
Correct |
75 ms |
15596 KB |
Output is correct |
41 |
Correct |
1 ms |
492 KB |
Output is correct |
42 |
Correct |
2 ms |
1516 KB |
Output is correct |
43 |
Correct |
570 ms |
51692 KB |
Output is correct |
44 |
Correct |
18 ms |
6124 KB |
Output is correct |
45 |
Incorrect |
582 ms |
53192 KB |
Output isn't correct |
46 |
Correct |
558 ms |
55660 KB |
Output is correct |
47 |
Incorrect |
554 ms |
53164 KB |
Output isn't correct |
48 |
Correct |
540 ms |
55660 KB |
Output is correct |
49 |
Correct |
608 ms |
55808 KB |
Output is correct |
50 |
Correct |
563 ms |
55788 KB |
Output is correct |
51 |
Correct |
542 ms |
55756 KB |
Output is correct |
52 |
Correct |
531 ms |
55660 KB |
Output is correct |
53 |
Correct |
528 ms |
55020 KB |
Output is correct |
54 |
Correct |
491 ms |
42348 KB |
Output is correct |
55 |
Incorrect |
490 ms |
40556 KB |
Output isn't correct |
56 |
Correct |
600 ms |
55936 KB |
Output is correct |
57 |
Incorrect |
482 ms |
35692 KB |
Output isn't correct |
58 |
Correct |
479 ms |
40684 KB |
Output is correct |
59 |
Correct |
496 ms |
37608 KB |
Output is correct |
60 |
Correct |
519 ms |
47468 KB |
Output is correct |
61 |
Correct |
587 ms |
55660 KB |
Output is correct |
62 |
Correct |
587 ms |
55788 KB |
Output is correct |
63 |
Correct |
604 ms |
55660 KB |
Output is correct |
64 |
Correct |
480 ms |
38764 KB |
Output is correct |
65 |
Correct |
517 ms |
54636 KB |
Output is correct |
66 |
Correct |
525 ms |
51472 KB |
Output is correct |
67 |
Correct |
547 ms |
55788 KB |
Output is correct |
68 |
Correct |
554 ms |
55916 KB |
Output is correct |
69 |
Correct |
475 ms |
35232 KB |
Output is correct |
70 |
Incorrect |
285 ms |
15340 KB |
Output isn't correct |
71 |
Incorrect |
468 ms |
28396 KB |
Output isn't correct |
72 |
Incorrect |
472 ms |
33772 KB |
Output isn't correct |
73 |
Correct |
491 ms |
34284 KB |
Output is correct |
74 |
Incorrect |
480 ms |
35692 KB |
Output isn't correct |
75 |
Incorrect |
484 ms |
37356 KB |
Output isn't correct |
76 |
Incorrect |
475 ms |
38764 KB |
Output isn't correct |
77 |
Incorrect |
521 ms |
39384 KB |
Output isn't correct |
78 |
Incorrect |
489 ms |
39404 KB |
Output isn't correct |
79 |
Incorrect |
416 ms |
11884 KB |
Output isn't correct |
80 |
Incorrect |
430 ms |
13292 KB |
Output isn't correct |
81 |
Incorrect |
425 ms |
13548 KB |
Output isn't correct |
82 |
Incorrect |
490 ms |
41876 KB |
Output isn't correct |
83 |
Incorrect |
491 ms |
42092 KB |
Output isn't correct |
84 |
Incorrect |
419 ms |
7324 KB |
Output isn't correct |
85 |
Incorrect |
494 ms |
40948 KB |
Output isn't correct |
86 |
Incorrect |
575 ms |
54680 KB |
Output isn't correct |
87 |
Incorrect |
488 ms |
39916 KB |
Output isn't correct |
88 |
Correct |
486 ms |
40972 KB |
Output is correct |
89 |
Correct |
516 ms |
49644 KB |
Output is correct |
90 |
Incorrect |
311 ms |
29548 KB |
Output isn't correct |
91 |
Incorrect |
494 ms |
44652 KB |
Output isn't correct |
92 |
Incorrect |
506 ms |
46444 KB |
Output isn't correct |
93 |
Incorrect |
568 ms |
53800 KB |
Output isn't correct |
94 |
Correct |
508 ms |
48256 KB |
Output is correct |
95 |
Incorrect |
488 ms |
42140 KB |
Output isn't correct |
96 |
Correct |
490 ms |
41836 KB |
Output is correct |
97 |
Incorrect |
562 ms |
54380 KB |
Output isn't correct |
98 |
Incorrect |
481 ms |
41580 KB |
Output isn't correct |
99 |
Incorrect |
511 ms |
47852 KB |
Output isn't correct |
100 |
Incorrect |
565 ms |
53228 KB |
Output isn't correct |