답안 #523099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523099 2022-02-07T04:20:59 Z dostigator Bomb (IZhO17_bomb) C++17
19 / 100
1000 ms 12560 KB
#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,cnt=0;
    if(n==1){
        ans=mod;
		for(int i=1; i<=m; ++i) {
			if(a[1][i]=='1') ++cnt;
			else{
				if(cnt>0) ans=min(ans,cnt);
				cnt=0;
			}
		}
		if(a[1][m]=='1') ans=min(ans,cnt);
		cout<<ans<<endl;
		return;
	}
	if(m==1){
	    ans=mod;
		for(int i=1; i<=n; ++i){
			if(a[i][1]=='1') ++cnt;
			else{
				if(cnt>0) ans=min(ans,cnt);
				cnt=0;
			}
		}
		if(a[n][1]=='1') ans=min(ans,cnt);
		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 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 244 KB Output is correct
8 Correct 2 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 204 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 1091 ms 204 KB Time limit exceeded
18 Execution timed out 1091 ms 204 KB Time limit exceeded
19 Execution timed out 1085 ms 332 KB Time limit exceeded
20 Execution timed out 1093 ms 204 KB Time limit exceeded
21 Execution timed out 1081 ms 204 KB Time limit exceeded
22 Execution timed out 1092 ms 204 KB Time limit exceeded
23 Execution timed out 1096 ms 332 KB Time limit exceeded
24 Execution timed out 1091 ms 204 KB Time limit exceeded
25 Execution timed out 1086 ms 332 KB Time limit exceeded
26 Execution timed out 1081 ms 332 KB Time limit exceeded
27 Execution timed out 1092 ms 460 KB Time limit exceeded
28 Execution timed out 1084 ms 460 KB Time limit exceeded
29 Execution timed out 1089 ms 460 KB Time limit exceeded
30 Execution timed out 1093 ms 588 KB Time limit exceeded
31 Execution timed out 1055 ms 588 KB Time limit exceeded
32 Execution timed out 1092 ms 588 KB Time limit exceeded
33 Execution timed out 1087 ms 716 KB Time limit exceeded
34 Execution timed out 1057 ms 460 KB Time limit exceeded
35 Execution timed out 1092 ms 716 KB Time limit exceeded
36 Execution timed out 1090 ms 588 KB Time limit exceeded
37 Correct 2 ms 204 KB Output is correct
38 Execution timed out 1091 ms 12492 KB Time limit exceeded
39 Correct 3 ms 204 KB Output is correct
40 Execution timed out 1077 ms 1740 KB Time limit exceeded
41 Correct 3 ms 204 KB Output is correct
42 Execution timed out 1080 ms 332 KB Time limit exceeded
43 Execution timed out 1082 ms 12492 KB Time limit exceeded
44 Execution timed out 1082 ms 716 KB Time limit exceeded
45 Execution timed out 1093 ms 12492 KB Time limit exceeded
46 Execution timed out 1093 ms 12492 KB Time limit exceeded
47 Execution timed out 1099 ms 12492 KB Time limit exceeded
48 Execution timed out 1092 ms 12492 KB Time limit exceeded
49 Execution timed out 1095 ms 12492 KB Time limit exceeded
50 Execution timed out 1084 ms 12492 KB Time limit exceeded
51 Execution timed out 1085 ms 12492 KB Time limit exceeded
52 Execution timed out 1098 ms 12492 KB Time limit exceeded
53 Execution timed out 1091 ms 12492 KB Time limit exceeded
54 Execution timed out 1081 ms 12492 KB Time limit exceeded
55 Execution timed out 1084 ms 12492 KB Time limit exceeded
56 Execution timed out 1092 ms 12492 KB Time limit exceeded
57 Execution timed out 1069 ms 12492 KB Time limit exceeded
58 Execution timed out 1087 ms 12492 KB Time limit exceeded
59 Execution timed out 1082 ms 12492 KB Time limit exceeded
60 Execution timed out 1094 ms 12492 KB Time limit exceeded
61 Execution timed out 1095 ms 12492 KB Time limit exceeded
62 Execution timed out 1069 ms 12492 KB Time limit exceeded
63 Execution timed out 1094 ms 12492 KB Time limit exceeded
64 Execution timed out 1093 ms 12492 KB Time limit exceeded
65 Execution timed out 1092 ms 12492 KB Time limit exceeded
66 Execution timed out 1067 ms 12492 KB Time limit exceeded
67 Execution timed out 1097 ms 12492 KB Time limit exceeded
68 Execution timed out 1096 ms 12492 KB Time limit exceeded
69 Execution timed out 1096 ms 12492 KB Time limit exceeded
70 Execution timed out 1092 ms 8140 KB Time limit exceeded
71 Execution timed out 1088 ms 12492 KB Time limit exceeded
72 Execution timed out 1095 ms 12492 KB Time limit exceeded
73 Execution timed out 1088 ms 12492 KB Time limit exceeded
74 Execution timed out 1091 ms 12492 KB Time limit exceeded
75 Execution timed out 1094 ms 12492 KB Time limit exceeded
76 Execution timed out 1088 ms 12492 KB Time limit exceeded
77 Execution timed out 1084 ms 12492 KB Time limit exceeded
78 Execution timed out 1052 ms 12536 KB Time limit exceeded
79 Execution timed out 1094 ms 12492 KB Time limit exceeded
80 Execution timed out 1088 ms 12492 KB Time limit exceeded
81 Execution timed out 1090 ms 12492 KB Time limit exceeded
82 Execution timed out 1092 ms 12556 KB Time limit exceeded
83 Execution timed out 1090 ms 12560 KB Time limit exceeded
84 Execution timed out 1089 ms 12492 KB Time limit exceeded
85 Execution timed out 1085 ms 12492 KB Time limit exceeded
86 Execution timed out 1092 ms 12492 KB Time limit exceeded
87 Execution timed out 1096 ms 12492 KB Time limit exceeded
88 Execution timed out 1078 ms 12492 KB Time limit exceeded
89 Execution timed out 1084 ms 12492 KB Time limit exceeded
90 Execution timed out 1091 ms 8140 KB Time limit exceeded
91 Execution timed out 1095 ms 12492 KB Time limit exceeded
92 Execution timed out 1093 ms 12492 KB Time limit exceeded
93 Execution timed out 1088 ms 12492 KB Time limit exceeded
94 Execution timed out 1087 ms 12492 KB Time limit exceeded
95 Execution timed out 1097 ms 12492 KB Time limit exceeded
96 Execution timed out 1100 ms 12492 KB Time limit exceeded
97 Execution timed out 1095 ms 12492 KB Time limit exceeded
98 Execution timed out 1099 ms 12492 KB Time limit exceeded
99 Execution timed out 1097 ms 12492 KB Time limit exceeded
100 Execution timed out 1100 ms 12492 KB Time limit exceeded