Submission #832311

# Submission time Handle Problem Language Result Execution time Memory
832311 2023-08-21T08:46:42 Z vjudge1 Bomb (IZhO17_bomb) C++14
16 / 100
1000 ms 55564 KB
#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

#define ll long long
#define rep(i,n,N) for(int i = n; i<=N; ++i)
#define rap(i,n,N) for(int i = n; i>=N; --i)
#define For(i,n,N) for(int i = n; i< N; ++i)
#define endl '\n'
#define pb push_back
#define all(x) x.begin(),x.end()
#define mems(x,y) memset(x,y,sizeof x)
#define ari(x) array<int,x>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first
#define se second
const int MAX = 2500 + 5;
mt19937 rng(time(NULL));

int n,m,mnr,mnc,cnt,y[MAX][MAX],z[MAX][MAX],ans,res;
char c;
bool x[MAX][MAX];
vector<ari(3)> v;

inline int fr(int k){
	int ret = n;
	rep(j,k,m){
		rep(i,1,n){
			if(z[i][j]-z[i][j-k]==k)++cnt;
			else if(cnt)ret = min(ret, cnt), cnt = 0;
		}
		if(cnt)ret = min(ret, cnt), cnt = 0;
	}
	return ret;
}

inline int fc(int k){
	int ret = m;
	rep(i,k,n){
		rep(j,1,m){
			if(y[i][j]-y[i-k][j]==k)++cnt;
			else if(cnt)ret = min(ret, cnt), cnt = 0;
		}
		if(cnt)ret = min(ret, cnt), cnt = 0;
	}
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	mnr = n, mnc = m;
	rep(i,1,n){
		rep(j,1,m){
			cin>>c;
			x[i][j] = c=='1';
			y[i][j] = y[i-1][j]+x[i][j];
			z[i][j] = z[i][j-1]+x[i][j];
			if(x[i][j])++cnt;
			else if(cnt)mnc = min(mnc, cnt), cnt = 0;
		}
		if(cnt)mnc = min(mnc, cnt), cnt = 0;
	}
	rep(j,1,m){
		rep(i,1,n){
			if(x[i][j])++cnt;
			else if(cnt)mnr = min(mnr, cnt), cnt = 0;
		}
		if(cnt)mnr = min(mnr, cnt), cnt = 0;
	}
	int r = 1, c = mnc;
	ans = max(mnr, mnc);
	while(c > 1){
		while(r<=mnr && r*c<=ans)++r;
		if(r>mnr)break;
		
		res = fr(c);
		ans = max(ans, res*c);
		r = res+1;
		
		res = fc(r);
		ans = max(ans, res*r);
		c = res-1;
	}
	cout<<ans<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 12 ms 26544 KB Output is correct
4 Correct 12 ms 26472 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Incorrect 0 ms 340 KB Output isn't correct
8 Execution timed out 1098 ms 468 KB Time limit exceeded
9 Incorrect 0 ms 468 KB Output isn't correct
10 Correct 0 ms 468 KB Output is correct
11 Execution timed out 1088 ms 468 KB Time limit exceeded
12 Correct 0 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Incorrect 0 ms 468 KB Output isn't correct
15 Execution timed out 1087 ms 468 KB Time limit exceeded
16 Incorrect 0 ms 468 KB Output isn't correct
17 Incorrect 1 ms 980 KB Output isn't correct
18 Correct 1 ms 1108 KB Output is correct
19 Execution timed out 1078 ms 1364 KB Time limit exceeded
20 Execution timed out 1086 ms 1364 KB Time limit exceeded
21 Correct 1 ms 852 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Execution timed out 1085 ms 1364 KB Time limit exceeded
24 Execution timed out 1072 ms 1236 KB Time limit exceeded
25 Execution timed out 1085 ms 1364 KB Time limit exceeded
26 Correct 1 ms 1364 KB Output is correct
27 Correct 3 ms 4052 KB Output is correct
28 Correct 3 ms 4180 KB Output is correct
29 Execution timed out 1092 ms 5332 KB Time limit exceeded
30 Execution timed out 1078 ms 6268 KB Time limit exceeded
31 Execution timed out 1079 ms 4948 KB Time limit exceeded
32 Execution timed out 1086 ms 5716 KB Time limit exceeded
33 Execution timed out 1082 ms 6612 KB Time limit exceeded
34 Correct 3 ms 4692 KB Output is correct
35 Execution timed out 1074 ms 6612 KB Time limit exceeded
36 Execution timed out 1082 ms 6612 KB Time limit exceeded
37 Execution timed out 1069 ms 468 KB Time limit exceeded
38 Incorrect 95 ms 55480 KB Output isn't correct
39 Execution timed out 1090 ms 468 KB Time limit exceeded
40 Execution timed out 1087 ms 15460 KB Time limit exceeded
41 Incorrect 1 ms 468 KB Output isn't correct
42 Execution timed out 1086 ms 1364 KB Time limit exceeded
43 Incorrect 146 ms 55472 KB Output isn't correct
44 Execution timed out 1097 ms 6612 KB Time limit exceeded
45 Execution timed out 1086 ms 55436 KB Time limit exceeded
46 Incorrect 152 ms 55412 KB Output isn't correct
47 Execution timed out 1080 ms 55424 KB Time limit exceeded
48 Execution timed out 1078 ms 55384 KB Time limit exceeded
49 Incorrect 146 ms 55384 KB Output isn't correct
50 Execution timed out 1087 ms 55384 KB Time limit exceeded
51 Execution timed out 1087 ms 55424 KB Time limit exceeded
52 Execution timed out 1084 ms 55380 KB Time limit exceeded
53 Execution timed out 1076 ms 55344 KB Time limit exceeded
54 Execution timed out 1069 ms 55368 KB Time limit exceeded
55 Execution timed out 1086 ms 55348 KB Time limit exceeded
56 Incorrect 145 ms 55388 KB Output isn't correct
57 Execution timed out 1097 ms 55412 KB Time limit exceeded
58 Execution timed out 1082 ms 55344 KB Time limit exceeded
59 Execution timed out 1087 ms 55372 KB Time limit exceeded
60 Incorrect 142 ms 55468 KB Output isn't correct
61 Incorrect 144 ms 55368 KB Output isn't correct
62 Incorrect 160 ms 55456 KB Output isn't correct
63 Incorrect 151 ms 55368 KB Output isn't correct
64 Incorrect 152 ms 55476 KB Output isn't correct
65 Execution timed out 1094 ms 55388 KB Time limit exceeded
66 Execution timed out 1058 ms 55564 KB Time limit exceeded
67 Execution timed out 1083 ms 55468 KB Time limit exceeded
68 Execution timed out 1062 ms 55372 KB Time limit exceeded
69 Execution timed out 1079 ms 55440 KB Time limit exceeded
70 Execution timed out 1079 ms 44356 KB Time limit exceeded
71 Execution timed out 1079 ms 55528 KB Time limit exceeded
72 Execution timed out 1078 ms 55372 KB Time limit exceeded
73 Execution timed out 1086 ms 55460 KB Time limit exceeded
74 Execution timed out 1082 ms 55344 KB Time limit exceeded
75 Execution timed out 1081 ms 55424 KB Time limit exceeded
76 Execution timed out 1070 ms 55412 KB Time limit exceeded
77 Execution timed out 1084 ms 55424 KB Time limit exceeded
78 Execution timed out 1088 ms 55464 KB Time limit exceeded
79 Execution timed out 1083 ms 55384 KB Time limit exceeded
80 Execution timed out 1086 ms 55384 KB Time limit exceeded
81 Execution timed out 1080 ms 55448 KB Time limit exceeded
82 Execution timed out 1079 ms 55460 KB Time limit exceeded
83 Execution timed out 1088 ms 55456 KB Time limit exceeded
84 Execution timed out 1081 ms 55444 KB Time limit exceeded
85 Execution timed out 1085 ms 55360 KB Time limit exceeded
86 Execution timed out 1073 ms 55508 KB Time limit exceeded
87 Execution timed out 1085 ms 55388 KB Time limit exceeded
88 Execution timed out 1086 ms 55428 KB Time limit exceeded
89 Execution timed out 1089 ms 55416 KB Time limit exceeded
90 Execution timed out 1085 ms 44376 KB Time limit exceeded
91 Execution timed out 1078 ms 55364 KB Time limit exceeded
92 Execution timed out 1070 ms 55428 KB Time limit exceeded
93 Execution timed out 1084 ms 55444 KB Time limit exceeded
94 Execution timed out 1083 ms 55372 KB Time limit exceeded
95 Execution timed out 1084 ms 55368 KB Time limit exceeded
96 Execution timed out 1082 ms 55452 KB Time limit exceeded
97 Execution timed out 1087 ms 55364 KB Time limit exceeded
98 Execution timed out 1074 ms 55376 KB Time limit exceeded
99 Execution timed out 1085 ms 55380 KB Time limit exceeded
100 Execution timed out 1087 ms 55440 KB Time limit exceeded