#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
using namespace std;
#define IShowSpeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcnt __builtin_popcount
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define mii map<int,int>
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define pb push_back
#define vt vector
#define endl '\n'
#define X first
#define Y second
typedef long double ld;
typedef long long ll;
const ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},N=1e6+10;
const ll mod=1e9+7,inf=1e18;
int dp[N];
void solve(){
int n,m;
cin>>n>>m;
char a[n+2][m+2],c[n+2][m+2];
for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) cin>>a[i][j];
int ans=0;
if(n==1 || m==1){
ans=mod;
if(n==1){
for(int i=1; i<=m; ++i){
dp[i]=dp[i-1];
if(a[1][i]=='1')dp[i]++;
if(a[1][i]=='0')dp[i]=0;
if(dp[i]) ans=min(ans,dp[i]);
}
if(ans==mod){
cout<<0<<endl;
return;
}
cout<<ans<<endl;
}
if(m==1){
for(int i=1; i<=n; ++i){
dp[i]=dp[i-1];
if(a[i][1]=='1')dp[i]++;
if(a[i][1]=='0')dp[i]=0;
if(dp[i]) ans=min(ans,dp[i]);
}
if(ans==mod){
cout<<0<<endl;
return;
}
cout<<ans<<endl;
}
return;
}
for(int x=1; x<=n; ++x){
for(int y=1; y<=m; ++y){
for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) c[i][j]=a[i][j];
for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j){
int bad=1;
if(i+x-1>n || j+y-1>m) continue;
for(int ol=i; ol<=i+x-1; ++ol) for(int zhas=j; zhas<=j+y-1; ++zhas) if(c[ol][zhas]=='0') bad=0;
if(bad) for(int ol=i; ol<=i+x-1; ++ol) for(int zhas=j; zhas<=j+y-1; ++zhas) c[ol][zhas]='2';
}
int ok=1;
for(int ol=1; ol<=n; ++ol) for(int zhas=1; zhas<=m; ++zhas) if(c[ol][zhas]=='1')ok=0;
if(ok)ans=max(ans,x*y);
}
}
cout<<ans<<endl;
}
int main() {
IShowSpeed;
int tt=1;
//cin>>tt;
while(tt--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
3 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
2 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
2 ms |
204 KB |
Output is correct |
16 |
Correct |
3 ms |
204 KB |
Output is correct |
17 |
Execution timed out |
1098 ms |
204 KB |
Time limit exceeded |
18 |
Execution timed out |
1085 ms |
204 KB |
Time limit exceeded |
19 |
Execution timed out |
1085 ms |
332 KB |
Time limit exceeded |
20 |
Execution timed out |
1094 ms |
204 KB |
Time limit exceeded |
21 |
Execution timed out |
1087 ms |
204 KB |
Time limit exceeded |
22 |
Execution timed out |
1082 ms |
204 KB |
Time limit exceeded |
23 |
Execution timed out |
1093 ms |
332 KB |
Time limit exceeded |
24 |
Execution timed out |
1098 ms |
204 KB |
Time limit exceeded |
25 |
Execution timed out |
1046 ms |
332 KB |
Time limit exceeded |
26 |
Execution timed out |
1092 ms |
332 KB |
Time limit exceeded |
27 |
Execution timed out |
1092 ms |
460 KB |
Time limit exceeded |
28 |
Execution timed out |
1093 ms |
460 KB |
Time limit exceeded |
29 |
Execution timed out |
1090 ms |
460 KB |
Time limit exceeded |
30 |
Execution timed out |
1083 ms |
588 KB |
Time limit exceeded |
31 |
Execution timed out |
1087 ms |
588 KB |
Time limit exceeded |
32 |
Execution timed out |
1083 ms |
588 KB |
Time limit exceeded |
33 |
Execution timed out |
1084 ms |
716 KB |
Time limit exceeded |
34 |
Execution timed out |
1089 ms |
460 KB |
Time limit exceeded |
35 |
Execution timed out |
1089 ms |
588 KB |
Time limit exceeded |
36 |
Execution timed out |
1086 ms |
588 KB |
Time limit exceeded |
37 |
Correct |
3 ms |
204 KB |
Output is correct |
38 |
Execution timed out |
1094 ms |
12552 KB |
Time limit exceeded |
39 |
Correct |
2 ms |
204 KB |
Output is correct |
40 |
Execution timed out |
1076 ms |
1740 KB |
Time limit exceeded |
41 |
Correct |
3 ms |
204 KB |
Output is correct |
42 |
Execution timed out |
1091 ms |
332 KB |
Time limit exceeded |
43 |
Execution timed out |
1086 ms |
12492 KB |
Time limit exceeded |
44 |
Execution timed out |
1087 ms |
716 KB |
Time limit exceeded |
45 |
Execution timed out |
1089 ms |
12492 KB |
Time limit exceeded |
46 |
Execution timed out |
1085 ms |
12492 KB |
Time limit exceeded |
47 |
Execution timed out |
1084 ms |
12492 KB |
Time limit exceeded |
48 |
Execution timed out |
1088 ms |
12492 KB |
Time limit exceeded |
49 |
Execution timed out |
1089 ms |
12492 KB |
Time limit exceeded |
50 |
Execution timed out |
1092 ms |
12492 KB |
Time limit exceeded |
51 |
Execution timed out |
1095 ms |
12492 KB |
Time limit exceeded |
52 |
Execution timed out |
1091 ms |
12492 KB |
Time limit exceeded |
53 |
Execution timed out |
1092 ms |
12492 KB |
Time limit exceeded |
54 |
Execution timed out |
1094 ms |
12492 KB |
Time limit exceeded |
55 |
Execution timed out |
1073 ms |
12492 KB |
Time limit exceeded |
56 |
Execution timed out |
1093 ms |
12492 KB |
Time limit exceeded |
57 |
Execution timed out |
1087 ms |
12492 KB |
Time limit exceeded |
58 |
Execution timed out |
1085 ms |
12492 KB |
Time limit exceeded |
59 |
Execution timed out |
1088 ms |
12492 KB |
Time limit exceeded |
60 |
Execution timed out |
1090 ms |
12492 KB |
Time limit exceeded |
61 |
Execution timed out |
1068 ms |
12492 KB |
Time limit exceeded |
62 |
Execution timed out |
1095 ms |
12492 KB |
Time limit exceeded |
63 |
Execution timed out |
1091 ms |
12492 KB |
Time limit exceeded |
64 |
Execution timed out |
1049 ms |
12492 KB |
Time limit exceeded |
65 |
Execution timed out |
1094 ms |
12492 KB |
Time limit exceeded |
66 |
Execution timed out |
1094 ms |
12492 KB |
Time limit exceeded |
67 |
Execution timed out |
1087 ms |
12448 KB |
Time limit exceeded |
68 |
Execution timed out |
1062 ms |
12708 KB |
Time limit exceeded |
69 |
Execution timed out |
1049 ms |
12740 KB |
Time limit exceeded |
70 |
Execution timed out |
1083 ms |
8388 KB |
Time limit exceeded |
71 |
Execution timed out |
1043 ms |
12716 KB |
Time limit exceeded |
72 |
Execution timed out |
1068 ms |
12740 KB |
Time limit exceeded |
73 |
Execution timed out |
1062 ms |
12756 KB |
Time limit exceeded |
74 |
Execution timed out |
1068 ms |
12792 KB |
Time limit exceeded |
75 |
Execution timed out |
1050 ms |
12740 KB |
Time limit exceeded |
76 |
Execution timed out |
1052 ms |
12744 KB |
Time limit exceeded |
77 |
Execution timed out |
1064 ms |
12708 KB |
Time limit exceeded |
78 |
Execution timed out |
1006 ms |
12792 KB |
Time limit exceeded |
79 |
Execution timed out |
1055 ms |
12744 KB |
Time limit exceeded |
80 |
Execution timed out |
1052 ms |
12700 KB |
Time limit exceeded |
81 |
Execution timed out |
1064 ms |
12744 KB |
Time limit exceeded |
82 |
Execution timed out |
1025 ms |
12696 KB |
Time limit exceeded |
83 |
Execution timed out |
1016 ms |
12696 KB |
Time limit exceeded |
84 |
Execution timed out |
1064 ms |
12696 KB |
Time limit exceeded |
85 |
Execution timed out |
1060 ms |
12792 KB |
Time limit exceeded |
86 |
Execution timed out |
1047 ms |
12732 KB |
Time limit exceeded |
87 |
Execution timed out |
1054 ms |
12868 KB |
Time limit exceeded |
88 |
Execution timed out |
1042 ms |
12768 KB |
Time limit exceeded |
89 |
Execution timed out |
1046 ms |
12736 KB |
Time limit exceeded |
90 |
Execution timed out |
1020 ms |
8296 KB |
Time limit exceeded |
91 |
Execution timed out |
1012 ms |
12692 KB |
Time limit exceeded |
92 |
Execution timed out |
1039 ms |
12768 KB |
Time limit exceeded |
93 |
Execution timed out |
1040 ms |
12708 KB |
Time limit exceeded |
94 |
Execution timed out |
1098 ms |
12740 KB |
Time limit exceeded |
95 |
Execution timed out |
1022 ms |
12740 KB |
Time limit exceeded |
96 |
Execution timed out |
1061 ms |
12740 KB |
Time limit exceeded |
97 |
Execution timed out |
1047 ms |
12740 KB |
Time limit exceeded |
98 |
Execution timed out |
1018 ms |
12704 KB |
Time limit exceeded |
99 |
Execution timed out |
1078 ms |
12740 KB |
Time limit exceeded |
100 |
Execution timed out |
1016 ms |
12740 KB |
Time limit exceeded |