Submission #523097

# Submission time Handle Problem Language Result Execution time Memory
523097 2022-02-07T04:15:43 Z dostigator Bomb (IZhO17_bomb) C++17
13 / 100
1000 ms 13500 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){
		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){
		for(int i=1; i<=n; ++i){
			if(a[i][1]=='1') ++cnt;
			else{
				if(cnt>0) ans=min(ans,cnt);
				cnt=0;
			}
		}
		if(c[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();
}

# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Incorrect 1 ms 324 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 324 KB Output isn't correct
6 Incorrect 1 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 324 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 320 KB Output is correct
16 Correct 3 ms 204 KB Output is correct
17 Execution timed out 1079 ms 332 KB Time limit exceeded
18 Execution timed out 1071 ms 204 KB Time limit exceeded
19 Execution timed out 1058 ms 332 KB Time limit exceeded
20 Execution timed out 1093 ms 332 KB Time limit exceeded
21 Execution timed out 1085 ms 332 KB Time limit exceeded
22 Execution timed out 1092 ms 332 KB Time limit exceeded
23 Execution timed out 1069 ms 332 KB Time limit exceeded
24 Execution timed out 1089 ms 332 KB Time limit exceeded
25 Execution timed out 1052 ms 332 KB Time limit exceeded
26 Execution timed out 1054 ms 336 KB Time limit exceeded
27 Execution timed out 1070 ms 460 KB Time limit exceeded
28 Execution timed out 1087 ms 588 KB Time limit exceeded
29 Execution timed out 1074 ms 588 KB Time limit exceeded
30 Execution timed out 1082 ms 804 KB Time limit exceeded
31 Execution timed out 1091 ms 716 KB Time limit exceeded
32 Execution timed out 1091 ms 716 KB Time limit exceeded
33 Execution timed out 1087 ms 844 KB Time limit exceeded
34 Execution timed out 1086 ms 460 KB Time limit exceeded
35 Execution timed out 1084 ms 844 KB Time limit exceeded
36 Execution timed out 1089 ms 844 KB Time limit exceeded
37 Correct 3 ms 204 KB Output is correct
38 Execution timed out 1055 ms 13392 KB Time limit exceeded
39 Correct 3 ms 324 KB Output is correct
40 Execution timed out 1075 ms 2512 KB Time limit exceeded
41 Correct 3 ms 204 KB Output is correct
42 Execution timed out 1052 ms 312 KB Time limit exceeded
43 Execution timed out 1053 ms 13368 KB Time limit exceeded
44 Execution timed out 1042 ms 844 KB Time limit exceeded
45 Execution timed out 1054 ms 13424 KB Time limit exceeded
46 Execution timed out 1042 ms 13376 KB Time limit exceeded
47 Execution timed out 1049 ms 13340 KB Time limit exceeded
48 Execution timed out 1058 ms 13380 KB Time limit exceeded
49 Execution timed out 1066 ms 13376 KB Time limit exceeded
50 Execution timed out 1056 ms 13376 KB Time limit exceeded
51 Execution timed out 1065 ms 13416 KB Time limit exceeded
52 Execution timed out 1026 ms 13380 KB Time limit exceeded
53 Execution timed out 1064 ms 13376 KB Time limit exceeded
54 Execution timed out 1074 ms 13380 KB Time limit exceeded
55 Execution timed out 1084 ms 13420 KB Time limit exceeded
56 Execution timed out 1063 ms 13380 KB Time limit exceeded
57 Execution timed out 1084 ms 13388 KB Time limit exceeded
58 Execution timed out 1049 ms 13380 KB Time limit exceeded
59 Execution timed out 1018 ms 13376 KB Time limit exceeded
60 Execution timed out 1046 ms 13432 KB Time limit exceeded
61 Execution timed out 1064 ms 13420 KB Time limit exceeded
62 Execution timed out 1047 ms 13420 KB Time limit exceeded
63 Execution timed out 1090 ms 13384 KB Time limit exceeded
64 Execution timed out 1056 ms 13500 KB Time limit exceeded
65 Execution timed out 1022 ms 13372 KB Time limit exceeded
66 Execution timed out 1028 ms 13384 KB Time limit exceeded
67 Execution timed out 1059 ms 13380 KB Time limit exceeded
68 Execution timed out 1026 ms 13124 KB Time limit exceeded
69 Execution timed out 1057 ms 13192 KB Time limit exceeded
70 Execution timed out 1045 ms 8720 KB Time limit exceeded
71 Execution timed out 1041 ms 13116 KB Time limit exceeded
72 Execution timed out 1022 ms 13028 KB Time limit exceeded
73 Execution timed out 1037 ms 13128 KB Time limit exceeded
74 Execution timed out 1031 ms 13128 KB Time limit exceeded
75 Execution timed out 1060 ms 13124 KB Time limit exceeded
76 Execution timed out 1094 ms 13176 KB Time limit exceeded
77 Execution timed out 1063 ms 13124 KB Time limit exceeded
78 Execution timed out 1054 ms 13024 KB Time limit exceeded
79 Execution timed out 1033 ms 13052 KB Time limit exceeded
80 Execution timed out 1044 ms 13048 KB Time limit exceeded
81 Execution timed out 1061 ms 13124 KB Time limit exceeded
82 Execution timed out 1092 ms 13112 KB Time limit exceeded
83 Execution timed out 1041 ms 13128 KB Time limit exceeded
84 Execution timed out 1088 ms 13120 KB Time limit exceeded
85 Execution timed out 1069 ms 13128 KB Time limit exceeded
86 Execution timed out 1054 ms 13112 KB Time limit exceeded
87 Execution timed out 1050 ms 13036 KB Time limit exceeded
88 Execution timed out 1094 ms 13128 KB Time limit exceeded
89 Execution timed out 1057 ms 13116 KB Time limit exceeded
90 Execution timed out 1061 ms 8696 KB Time limit exceeded
91 Execution timed out 1068 ms 13140 KB Time limit exceeded
92 Execution timed out 1047 ms 13144 KB Time limit exceeded
93 Execution timed out 1029 ms 13068 KB Time limit exceeded
94 Execution timed out 1067 ms 13088 KB Time limit exceeded
95 Execution timed out 1057 ms 13120 KB Time limit exceeded
96 Execution timed out 1028 ms 13048 KB Time limit exceeded
97 Execution timed out 1062 ms 13096 KB Time limit exceeded
98 Execution timed out 1029 ms 13024 KB Time limit exceeded
99 Execution timed out 1072 ms 13116 KB Time limit exceeded
100 Execution timed out 1034 ms 13096 KB Time limit exceeded