Submission #334309

# Submission time Handle Problem Language Result Execution time Memory
334309 2020-12-09T02:13:13 Z juggernaut Bomb (IZhO17_bomb) C++14
0 / 100
1000 ms 512 KB
#include<bits/stdc++.h>
using namespace std;
template<class T>void umin(T& a,T b){if(b<a)a=b;}
template<class T>void umax(T& a,T b){if(b>a)a=b;}
int n,m,xx,yy,up[2505][2505],down[2505][2505],ans[2505];
bool ar[2505][2505];
char rd(){
    char ch;
    do{
        scanf("%c",&ch);
    }while(ch!='0'&&ch!='1');
}
int main(){
    scanf("%d%d",&n,&m);
    xx=n,yy=m;
    for(int i=1;i<=n;i++){
        int cnt=0;
        for(int j=1;j<=m;j++){
            ar[i][j]=(rd()=='1');
            if(ar[i][j])cnt++;
            else{
                if(cnt)umin(yy,cnt);
                cnt=0;
            }
        }
        if(cnt)umin(yy,cnt);
    }
    cout<<"OK";
    for(int j=1;j<=m;j++){
        int cnt=0;
        for(int i=1;i<=n;i++){
            if(ar[i][j]){
                cnt++;
                up[i][j]=up[i-1][j]+1;
            }else{
                if(cnt)umin(xx,cnt);
                cnt=0;
            }
        }
        if(cnt)umin(xx,cnt);
        for(int i=n;i>0;i--)if(ar[i][j])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=2e9,b=2e9;
        for(int j=1;j<=m;j++){
			if(ar[i][j]){
				umin(a,up[i][j]);
				umin(b,down[i][j]);
				umin(ans[++cnt],a+b-1);
			}else{
			    cnt=0;
			    a=b=2e9;
			}
		}
		cnt=0;
        a=2e9,b=2e9;
        for(int j=m;j>0;j--){
			if(ar[i][j]){
				umin(a,up[i][j]);
				umin(b,down[i][j]);
				umin(ans[++cnt],a+b-1);
			}else{
			    cnt=0;
			    a=b=2e9;
			}
		}
    }
    int res=ans[1];
	for(int i=2;i<=yy;i++){
		umin(ans[i],ans[i-1]);
		umax(res,i*ans[i]);
	}
	printf("%d",res);
}

Compilation message

bomb.cpp: In function 'char rd()':
bomb.cpp:12:1: warning: no return statement in function returning non-void [-Wreturn-type]
   12 | }
      | ^
bomb.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |         scanf("%c",&ch);
      |         ~~~~~^~~~~~~~~~
bomb.cpp: In function 'int main()':
bomb.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 364 KB Time limit exceeded
2 Execution timed out 1095 ms 364 KB Time limit exceeded
3 Execution timed out 1093 ms 364 KB Time limit exceeded
4 Execution timed out 1096 ms 364 KB Time limit exceeded
5 Execution timed out 1094 ms 384 KB Time limit exceeded
6 Execution timed out 1046 ms 364 KB Time limit exceeded
7 Execution timed out 1079 ms 364 KB Time limit exceeded
8 Execution timed out 1087 ms 364 KB Time limit exceeded
9 Execution timed out 1096 ms 364 KB Time limit exceeded
10 Execution timed out 1078 ms 364 KB Time limit exceeded
11 Execution timed out 1084 ms 364 KB Time limit exceeded
12 Execution timed out 1098 ms 364 KB Time limit exceeded
13 Execution timed out 1076 ms 364 KB Time limit exceeded
14 Execution timed out 1093 ms 364 KB Time limit exceeded
15 Execution timed out 1073 ms 364 KB Time limit exceeded
16 Execution timed out 1060 ms 364 KB Time limit exceeded
17 Execution timed out 1052 ms 364 KB Time limit exceeded
18 Execution timed out 1099 ms 364 KB Time limit exceeded
19 Execution timed out 1099 ms 364 KB Time limit exceeded
20 Execution timed out 1076 ms 364 KB Time limit exceeded
21 Execution timed out 1086 ms 364 KB Time limit exceeded
22 Execution timed out 1054 ms 364 KB Time limit exceeded
23 Execution timed out 1095 ms 364 KB Time limit exceeded
24 Execution timed out 1083 ms 364 KB Time limit exceeded
25 Execution timed out 1064 ms 364 KB Time limit exceeded
26 Execution timed out 1078 ms 364 KB Time limit exceeded
27 Execution timed out 1038 ms 364 KB Time limit exceeded
28 Execution timed out 1092 ms 364 KB Time limit exceeded
29 Execution timed out 1077 ms 364 KB Time limit exceeded
30 Execution timed out 1086 ms 364 KB Time limit exceeded
31 Execution timed out 1086 ms 364 KB Time limit exceeded
32 Execution timed out 1091 ms 364 KB Time limit exceeded
33 Execution timed out 1041 ms 364 KB Time limit exceeded
34 Execution timed out 1087 ms 364 KB Time limit exceeded
35 Execution timed out 1087 ms 364 KB Time limit exceeded
36 Execution timed out 1088 ms 364 KB Time limit exceeded
37 Execution timed out 1086 ms 364 KB Time limit exceeded
38 Execution timed out 1087 ms 364 KB Time limit exceeded
39 Execution timed out 1090 ms 364 KB Time limit exceeded
40 Execution timed out 1088 ms 364 KB Time limit exceeded
41 Execution timed out 1051 ms 364 KB Time limit exceeded
42 Execution timed out 1089 ms 364 KB Time limit exceeded
43 Execution timed out 1085 ms 364 KB Time limit exceeded
44 Execution timed out 1090 ms 364 KB Time limit exceeded
45 Execution timed out 1047 ms 364 KB Time limit exceeded
46 Execution timed out 1091 ms 364 KB Time limit exceeded
47 Execution timed out 1087 ms 364 KB Time limit exceeded
48 Execution timed out 1048 ms 364 KB Time limit exceeded
49 Execution timed out 1099 ms 364 KB Time limit exceeded
50 Execution timed out 1057 ms 364 KB Time limit exceeded
51 Execution timed out 1088 ms 364 KB Time limit exceeded
52 Execution timed out 1067 ms 512 KB Time limit exceeded
53 Execution timed out 1068 ms 364 KB Time limit exceeded
54 Execution timed out 1084 ms 512 KB Time limit exceeded
55 Execution timed out 1082 ms 364 KB Time limit exceeded
56 Execution timed out 1088 ms 364 KB Time limit exceeded
57 Execution timed out 1093 ms 364 KB Time limit exceeded
58 Execution timed out 1098 ms 364 KB Time limit exceeded
59 Execution timed out 1082 ms 364 KB Time limit exceeded
60 Execution timed out 1093 ms 364 KB Time limit exceeded
61 Execution timed out 1087 ms 364 KB Time limit exceeded
62 Execution timed out 1057 ms 364 KB Time limit exceeded
63 Execution timed out 1064 ms 364 KB Time limit exceeded
64 Execution timed out 1058 ms 268 KB Time limit exceeded
65 Execution timed out 1090 ms 364 KB Time limit exceeded
66 Execution timed out 1092 ms 364 KB Time limit exceeded
67 Execution timed out 1046 ms 364 KB Time limit exceeded
68 Execution timed out 1091 ms 364 KB Time limit exceeded
69 Execution timed out 1057 ms 364 KB Time limit exceeded
70 Execution timed out 1091 ms 364 KB Time limit exceeded
71 Execution timed out 1070 ms 364 KB Time limit exceeded
72 Execution timed out 1078 ms 512 KB Time limit exceeded
73 Execution timed out 1077 ms 364 KB Time limit exceeded
74 Execution timed out 1074 ms 364 KB Time limit exceeded
75 Execution timed out 1089 ms 364 KB Time limit exceeded
76 Execution timed out 1052 ms 364 KB Time limit exceeded
77 Execution timed out 1080 ms 364 KB Time limit exceeded
78 Execution timed out 1084 ms 364 KB Time limit exceeded
79 Execution timed out 1080 ms 364 KB Time limit exceeded
80 Execution timed out 1035 ms 364 KB Time limit exceeded
81 Execution timed out 1084 ms 364 KB Time limit exceeded
82 Execution timed out 1097 ms 364 KB Time limit exceeded
83 Execution timed out 1103 ms 364 KB Time limit exceeded
84 Execution timed out 1068 ms 364 KB Time limit exceeded
85 Execution timed out 1062 ms 364 KB Time limit exceeded
86 Execution timed out 1085 ms 268 KB Time limit exceeded
87 Execution timed out 1061 ms 364 KB Time limit exceeded
88 Execution timed out 1056 ms 364 KB Time limit exceeded
89 Execution timed out 1098 ms 364 KB Time limit exceeded
90 Execution timed out 1084 ms 364 KB Time limit exceeded
91 Execution timed out 1050 ms 364 KB Time limit exceeded
92 Execution timed out 1072 ms 364 KB Time limit exceeded
93 Execution timed out 1085 ms 364 KB Time limit exceeded
94 Execution timed out 1083 ms 364 KB Time limit exceeded
95 Execution timed out 1082 ms 364 KB Time limit exceeded
96 Execution timed out 1088 ms 364 KB Time limit exceeded
97 Execution timed out 1093 ms 364 KB Time limit exceeded
98 Execution timed out 1099 ms 364 KB Time limit exceeded
99 Execution timed out 1099 ms 364 KB Time limit exceeded
100 Execution timed out 1084 ms 364 KB Time limit exceeded