Submission #832306

# Submission time Handle Problem Language Result Execution time Memory
832306 2023-08-21T08:42:49 Z vjudge1 Bomb (IZhO17_bomb) C++14
36 / 100
1000 ms 55656 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){
		res = fr(c);
		ans = max(ans, res*c);
		r = max(r+1, res);
		while(r<=mnr && r*c<=ans)++r;
		if(r>mnr)break;
		res = fc(r);
		ans = max(ans, res*r);
		c = min(c-1, res);
	}
	cout<<ans<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 12 ms 26460 KB Output is correct
4 Correct 12 ms 26540 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Incorrect 1 ms 468 KB Output isn't correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Incorrect 1 ms 980 KB Output isn't correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1364 KB Output is correct
20 Incorrect 1 ms 1364 KB Output isn't correct
21 Correct 1 ms 852 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Incorrect 1 ms 1364 KB Output isn't correct
24 Incorrect 1 ms 1236 KB Output isn't correct
25 Incorrect 1 ms 1364 KB Output isn't correct
26 Correct 1 ms 1364 KB Output is correct
27 Correct 3 ms 4052 KB Output is correct
28 Correct 4 ms 4180 KB Output is correct
29 Correct 9 ms 5332 KB Output is correct
30 Incorrect 5 ms 6228 KB Output isn't correct
31 Incorrect 5 ms 5028 KB Output isn't correct
32 Incorrect 7 ms 5716 KB Output isn't correct
33 Incorrect 6 ms 6612 KB Output isn't correct
34 Correct 4 ms 4692 KB Output is correct
35 Incorrect 9 ms 6740 KB Output isn't correct
36 Incorrect 6 ms 6612 KB Output isn't correct
37 Incorrect 1 ms 468 KB Output isn't correct
38 Correct 89 ms 55364 KB Output is correct
39 Incorrect 0 ms 468 KB Output isn't correct
40 Incorrect 21 ms 15548 KB Output isn't correct
41 Incorrect 0 ms 468 KB Output isn't correct
42 Incorrect 1 ms 1364 KB Output isn't correct
43 Correct 151 ms 55456 KB Output is correct
44 Incorrect 25 ms 6612 KB Output isn't correct
45 Execution timed out 1083 ms 55368 KB Time limit exceeded
46 Correct 136 ms 55480 KB Output is correct
47 Execution timed out 1094 ms 55428 KB Time limit exceeded
48 Incorrect 196 ms 55564 KB Output isn't correct
49 Correct 149 ms 55400 KB Output is correct
50 Incorrect 217 ms 55468 KB Output isn't correct
51 Incorrect 200 ms 55452 KB Output isn't correct
52 Incorrect 202 ms 55472 KB Output isn't correct
53 Incorrect 211 ms 55400 KB Output isn't correct
54 Execution timed out 1085 ms 55380 KB Time limit exceeded
55 Execution timed out 1078 ms 55392 KB Time limit exceeded
56 Correct 140 ms 55348 KB Output is correct
57 Execution timed out 1093 ms 55532 KB Time limit exceeded
58 Execution timed out 1091 ms 55376 KB Time limit exceeded
59 Execution timed out 1088 ms 55372 KB Time limit exceeded
60 Correct 147 ms 55468 KB Output is correct
61 Correct 143 ms 55400 KB Output is correct
62 Correct 178 ms 55476 KB Output is correct
63 Correct 157 ms 55412 KB Output is correct
64 Correct 145 ms 55432 KB Output is correct
65 Incorrect 210 ms 55468 KB Output isn't correct
66 Incorrect 229 ms 55476 KB Output isn't correct
67 Incorrect 212 ms 55472 KB Output isn't correct
68 Incorrect 232 ms 55412 KB Output isn't correct
69 Execution timed out 1101 ms 55376 KB Time limit exceeded
70 Incorrect 190 ms 44452 KB Output isn't correct
71 Incorrect 330 ms 55472 KB Output isn't correct
72 Incorrect 342 ms 55436 KB Output isn't correct
73 Incorrect 323 ms 55472 KB Output isn't correct
74 Incorrect 279 ms 55468 KB Output isn't correct
75 Incorrect 372 ms 55468 KB Output isn't correct
76 Incorrect 276 ms 55372 KB Output isn't correct
77 Incorrect 350 ms 55472 KB Output isn't correct
78 Incorrect 321 ms 55352 KB Output isn't correct
79 Incorrect 139 ms 55448 KB Output isn't correct
80 Incorrect 144 ms 55468 KB Output isn't correct
81 Incorrect 259 ms 55420 KB Output isn't correct
82 Incorrect 328 ms 55472 KB Output isn't correct
83 Incorrect 269 ms 55472 KB Output isn't correct
84 Incorrect 199 ms 55468 KB Output isn't correct
85 Incorrect 310 ms 55468 KB Output isn't correct
86 Correct 199 ms 55508 KB Output is correct
87 Correct 207 ms 55436 KB Output is correct
88 Incorrect 318 ms 55440 KB Output isn't correct
89 Incorrect 317 ms 55420 KB Output isn't correct
90 Incorrect 155 ms 44456 KB Output isn't correct
91 Incorrect 259 ms 55476 KB Output isn't correct
92 Incorrect 324 ms 55656 KB Output isn't correct
93 Incorrect 284 ms 55472 KB Output isn't correct
94 Incorrect 320 ms 55520 KB Output isn't correct
95 Incorrect 331 ms 55476 KB Output isn't correct
96 Incorrect 336 ms 55468 KB Output isn't correct
97 Incorrect 244 ms 55384 KB Output isn't correct
98 Incorrect 344 ms 55436 KB Output isn't correct
99 Incorrect 324 ms 55468 KB Output isn't correct
100 Incorrect 245 ms 55472 KB Output isn't correct