Submission #884609

# Submission time Handle Problem Language Result Execution time Memory
884609 2023-12-07T18:11:25 Z tsumondai Bomb (IZhO17_bomb) C++14
100 / 100
98 ms 80148 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)
#define __TIME  (1.0 * clock() / CLOCKS_PER_SEC)

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 2500+ 5;

const int oo = 1e9, mod = 1e9 + 7;

int a[N][N], u[N][N], d[N][N], ans[N];

void process() {
	int mnr = oo, mnc = oo;
	int n, m;
	cin >> n >> m;
	foru(i,1,n) {
		foru(j,1,m) {
			char c;
			cin >> c;
			a[i][j] = c - '0';
		}
	}

	foru(i,1,n) {
		foru(j,1,m) {
			if (a[i][j]) u[i][j] = u[i - 1][j] + 1;
		}
	}

	for (int i = n; i > 0; i--) {
		foru(j,1,m) {
			if (a[i][j]) {
				d[i][j] = d[i + 1][j] + 1;
				if (a[i + 1][j] == 0) mnc = min(mnc, u[i][j]);
			}
		}
	}


	foru(i,1,m) ans[i] = mnc;

	foru(i,1,n) {
		int aa = oo, b = oo, c = 0;
		foru(j,1,m) {
			if (a[i][j] == 0) {
				if (c != 0) mnc = min(c, mnc);
				aa = b = oo, c = 0;
			} else {
				aa = min(aa, d[i][j]);
				b = min(b, u[i][j]);
				c++;
				ans[c] = min(ans[c], b + aa - 1);
			}
		}

		aa = oo, b = oo, c = 0;
		ford(j,m,0) {
			if (a[i][j] == 0) {
				if (c != 0) mnr = min(mnr, c);
				aa = b = oo, c = 0;
			} else {
				aa = min(d[i][j], aa);
				b = min(u[i][j], b);
				c++;
				ans[c] = min(ans[c], b + aa - 1);
			}
		}
		if (c > 0) mnr = min(mnr, c);
	}
	int mx = 0;
	foru(i,1,mnr) {
		mx = max(ans[i] * i, mx);
	}
	cout << mx << "\n";
	return;
}

signed main() {
	cin.tie(0)->sync_with_stdio(false);
	//freopen(".inp", "r", stdin);
	//freopen(".out", "w", stdout);
	process();
	cerr << "Time elapsed: " << __TIME << " s.\n";
	return 0;
}

// dont stop
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 14 ms 71560 KB Output is correct
4 Correct 10 ms 71684 KB Output is correct
5 Correct 1 ms 2512 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2520 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2516 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2516 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2528 KB Output is correct
16 Correct 1 ms 2512 KB Output is correct
17 Correct 2 ms 7004 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 2 ms 6748 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 1 ms 4700 KB Output is correct
22 Correct 1 ms 6748 KB Output is correct
23 Correct 1 ms 6872 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 1 ms 6872 KB Output is correct
26 Correct 2 ms 7004 KB Output is correct
27 Correct 4 ms 13404 KB Output is correct
28 Correct 3 ms 9052 KB Output is correct
29 Correct 5 ms 13832 KB Output is correct
30 Correct 4 ms 13404 KB Output is correct
31 Correct 3 ms 9820 KB Output is correct
32 Correct 4 ms 13404 KB Output is correct
33 Correct 5 ms 15964 KB Output is correct
34 Correct 3 ms 9052 KB Output is correct
35 Correct 4 ms 11096 KB Output is correct
36 Correct 5 ms 19356 KB Output is correct
37 Correct 1 ms 2652 KB Output is correct
38 Correct 94 ms 80144 KB Output is correct
39 Correct 1 ms 2652 KB Output is correct
40 Correct 15 ms 32472 KB Output is correct
41 Correct 1 ms 2512 KB Output is correct
42 Correct 1 ms 7004 KB Output is correct
43 Correct 89 ms 79188 KB Output is correct
44 Correct 5 ms 19288 KB Output is correct
45 Correct 89 ms 79700 KB Output is correct
46 Correct 91 ms 80076 KB Output is correct
47 Correct 90 ms 79940 KB Output is correct
48 Correct 91 ms 79952 KB Output is correct
49 Correct 95 ms 79956 KB Output is correct
50 Correct 92 ms 79952 KB Output is correct
51 Correct 92 ms 80148 KB Output is correct
52 Correct 89 ms 79944 KB Output is correct
53 Correct 90 ms 80052 KB Output is correct
54 Correct 86 ms 78936 KB Output is correct
55 Correct 91 ms 78416 KB Output is correct
56 Correct 97 ms 79960 KB Output is correct
57 Correct 83 ms 72528 KB Output is correct
58 Correct 84 ms 79056 KB Output is correct
59 Correct 83 ms 76748 KB Output is correct
60 Correct 97 ms 79196 KB Output is correct
61 Correct 93 ms 80092 KB Output is correct
62 Correct 92 ms 79952 KB Output is correct
63 Correct 94 ms 79952 KB Output is correct
64 Correct 95 ms 79244 KB Output is correct
65 Correct 90 ms 79956 KB Output is correct
66 Correct 90 ms 79956 KB Output is correct
67 Correct 96 ms 79960 KB Output is correct
68 Correct 96 ms 80096 KB Output is correct
69 Correct 90 ms 70076 KB Output is correct
70 Correct 52 ms 42324 KB Output is correct
71 Correct 82 ms 68072 KB Output is correct
72 Correct 88 ms 68944 KB Output is correct
73 Correct 89 ms 68692 KB Output is correct
74 Correct 88 ms 72996 KB Output is correct
75 Correct 91 ms 76116 KB Output is correct
76 Correct 87 ms 76880 KB Output is correct
77 Correct 91 ms 76888 KB Output is correct
78 Correct 93 ms 77144 KB Output is correct
79 Correct 77 ms 43856 KB Output is correct
80 Correct 77 ms 47952 KB Output is correct
81 Correct 86 ms 47432 KB Output is correct
82 Correct 93 ms 78664 KB Output is correct
83 Correct 93 ms 79068 KB Output is correct
84 Correct 75 ms 35156 KB Output is correct
85 Correct 86 ms 79592 KB Output is correct
86 Correct 97 ms 79696 KB Output is correct
87 Correct 85 ms 79444 KB Output is correct
88 Correct 87 ms 77520 KB Output is correct
89 Correct 90 ms 79956 KB Output is correct
90 Correct 64 ms 66888 KB Output is correct
91 Correct 90 ms 79748 KB Output is correct
92 Correct 94 ms 79956 KB Output is correct
93 Correct 96 ms 79896 KB Output is correct
94 Correct 98 ms 79956 KB Output is correct
95 Correct 85 ms 78932 KB Output is correct
96 Correct 89 ms 78656 KB Output is correct
97 Correct 92 ms 79748 KB Output is correct
98 Correct 97 ms 78676 KB Output is correct
99 Correct 87 ms 79828 KB Output is correct
100 Correct 91 ms 79820 KB Output is correct