Submission #223999

# Submission time Handle Problem Language Result Execution time Memory
223999 2020-04-17T01:55:26 Z super_j6 Bomb (IZhO17_bomb) C++14
100 / 100
370 ms 74012 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int maxn = 2500;
int n, m;
int a[maxn][maxn], u[maxn][maxn], d[maxn][maxn];
int dp[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	
	for(int i = 0; i < n; i++)
	for(int j = 0; j < m; j++){
		char c;
		cin >> c;
		a[i][j] = c - '0';
	}
	
	for(int j = 0; j < m; j++){
		dp[j] = n;
		u[n - 1][j] = n - 1;
		for(int i = 1; i < n; i++){
			d[i][j] = !a[i][j] || !a[i - 1][j] ? i : d[i - 1][j];
			u[n - i - 1][j] = !a[n - i - 1][j] || !a[n - i][j] ? n - i - 1 : u[n - i][j];
		}
	}
	
	for(int i = 0; i < n; i++)
	for(int j = 0, l = 0, ul = n - 1, dl = 0, r = m - 1, ur = n - 1, dr = 0; j < m; j++){
		if(a[i][j]){
			dp[0] = min(dp[0], u[i][j] - d[i][j] + 1);
			ul = min(ul, u[i][j]), dl = max(dl, d[i][j]);
			dp[j - l] = min(dp[j - l], ul - dl + 1);
		}else{
			if(j > l) dp[j - l] = 0;
			l = j + 1;
			ul = n - 1, dl = 0;
		}
		if(a[i][m - j - 1]){
			ur = min(ur, u[i][m - j - 1]), dr = max(dr, d[i][m - j - 1]);
			dp[r + j + 1 - m] = min(dp[r + j + 1 - m], ur - dr + 1);
		}else{
			if(m - j - 1 < r) dp[r + j + 1 - m] = 0;
			r = m - j - 2;
			ur = n - 1, dr = 0;
		}
	}
	
	int ret = 0;
	for(int i = 0; i < m; i++){
		if(i) dp[i] = min(dp[i], dp[i - 1]);
		ret = max(ret, (i + 1) * dp[i]);
	}
	
	cout << ret << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
3 Correct 16 ms 30464 KB Output is correct
4 Correct 16 ms 30464 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 512 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 4 ms 640 KB Output is correct
12 Correct 4 ms 512 KB Output is correct
13 Correct 4 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 4 ms 512 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 1152 KB Output is correct
18 Correct 5 ms 1280 KB Output is correct
19 Correct 5 ms 1536 KB Output is correct
20 Correct 5 ms 1536 KB Output is correct
21 Correct 5 ms 1024 KB Output is correct
22 Correct 5 ms 1408 KB Output is correct
23 Correct 5 ms 1664 KB Output is correct
24 Correct 5 ms 1408 KB Output is correct
25 Correct 5 ms 1664 KB Output is correct
26 Correct 5 ms 1664 KB Output is correct
27 Correct 8 ms 4864 KB Output is correct
28 Correct 9 ms 5120 KB Output is correct
29 Correct 10 ms 6528 KB Output is correct
30 Correct 12 ms 7680 KB Output is correct
31 Correct 10 ms 6144 KB Output is correct
32 Correct 11 ms 7016 KB Output is correct
33 Correct 13 ms 8192 KB Output is correct
34 Correct 9 ms 5632 KB Output is correct
35 Correct 15 ms 8064 KB Output is correct
36 Correct 13 ms 8064 KB Output is correct
37 Correct 4 ms 640 KB Output is correct
38 Correct 351 ms 73720 KB Output is correct
39 Correct 5 ms 640 KB Output is correct
40 Correct 46 ms 19960 KB Output is correct
41 Correct 5 ms 640 KB Output is correct
42 Correct 5 ms 1664 KB Output is correct
43 Correct 355 ms 73848 KB Output is correct
44 Correct 13 ms 8192 KB Output is correct
45 Correct 344 ms 73824 KB Output is correct
46 Correct 345 ms 73720 KB Output is correct
47 Correct 338 ms 73720 KB Output is correct
48 Correct 349 ms 73824 KB Output is correct
49 Correct 361 ms 73720 KB Output is correct
50 Correct 344 ms 73720 KB Output is correct
51 Correct 349 ms 73720 KB Output is correct
52 Correct 349 ms 73720 KB Output is correct
53 Correct 347 ms 73828 KB Output is correct
54 Correct 331 ms 73776 KB Output is correct
55 Correct 331 ms 73720 KB Output is correct
56 Correct 354 ms 73720 KB Output is correct
57 Correct 330 ms 73848 KB Output is correct
58 Correct 335 ms 73720 KB Output is correct
59 Correct 347 ms 73848 KB Output is correct
60 Correct 330 ms 73720 KB Output is correct
61 Correct 348 ms 73720 KB Output is correct
62 Correct 344 ms 73848 KB Output is correct
63 Correct 362 ms 73808 KB Output is correct
64 Correct 353 ms 73744 KB Output is correct
65 Correct 354 ms 73784 KB Output is correct
66 Correct 350 ms 73828 KB Output is correct
67 Correct 365 ms 73720 KB Output is correct
68 Correct 358 ms 73976 KB Output is correct
69 Correct 342 ms 73720 KB Output is correct
70 Correct 222 ms 59132 KB Output is correct
71 Correct 346 ms 73820 KB Output is correct
72 Correct 335 ms 73848 KB Output is correct
73 Correct 341 ms 73720 KB Output is correct
74 Correct 338 ms 73720 KB Output is correct
75 Correct 342 ms 74012 KB Output is correct
76 Correct 335 ms 73720 KB Output is correct
77 Correct 342 ms 73776 KB Output is correct
78 Correct 336 ms 73720 KB Output is correct
79 Correct 331 ms 73848 KB Output is correct
80 Correct 331 ms 73720 KB Output is correct
81 Correct 332 ms 73752 KB Output is correct
82 Correct 337 ms 73696 KB Output is correct
83 Correct 348 ms 73848 KB Output is correct
84 Correct 332 ms 73788 KB Output is correct
85 Correct 338 ms 73720 KB Output is correct
86 Correct 370 ms 73720 KB Output is correct
87 Correct 343 ms 73720 KB Output is correct
88 Correct 355 ms 73720 KB Output is correct
89 Correct 347 ms 73720 KB Output is correct
90 Correct 225 ms 59128 KB Output is correct
91 Correct 354 ms 73720 KB Output is correct
92 Correct 339 ms 73720 KB Output is correct
93 Correct 358 ms 73720 KB Output is correct
94 Correct 343 ms 73720 KB Output is correct
95 Correct 340 ms 73848 KB Output is correct
96 Correct 339 ms 73720 KB Output is correct
97 Correct 364 ms 73736 KB Output is correct
98 Correct 340 ms 73700 KB Output is correct
99 Correct 346 ms 73712 KB Output is correct
100 Correct 340 ms 73720 KB Output is correct