답안 #711553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
711553 2023-03-17T08:29:08 Z pavement Bomb (IZhO17_bomb) C++17
90 / 100
234 ms 110868 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using db = double;
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using iii = tuple<int, int, int>;
using iiii = tuple<int, int, int, int>;
template<class key, class value = null_type, class cmp = less<key> >
using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

int N, M, ans[2505], top[2505][2505], down[2505][2505];
char A[2505][2505];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		ans[i] = (int)1e16;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (A[i][j] == '1') {
				top[i][j] = (top[i - 1][j] ? top[i - 1][j] : i);
			}
		}
	}
	for (int i = N; i >= 1; i--) {
		for (int j = 1; j <= M; j++) {
			if (A[i][j] == '1') {
				down[i][j] = (down[i + 1][j] ? down[i + 1][j] : i);
			}
		}
	}
	for (int iter = 0; iter < 2; iter++) {
		for (int i = 1; i <= N; i++) {
			for (int l = 1, r = 1; l <= M; ) {
				while (r <= M && A[i][r] == '1') r++;
				if (l == r) {
					l++;
					r++;
					continue;
				}
				ans[r - l + 1] = 0;
				int min_top = (int)1e16, min_down = (int)1e16;
				for (int j = l; j < r; j++) {
					min_top = min(min_top, i - top[i][j] + 1);
					min_down = min(min_down, down[i][j] - i + 1);
					ans[j - l + 1] = min(ans[j - l + 1], min_top + min_down - 1);
				}
				l = r;
			}
		}
		for (int i = 1; i <= N; i++) {
			reverse(A[i] + 1, A[i] + 1 + M);
			reverse(top[i] + 1, top[i] + 1 + M);
			reverse(down[i] + 1, down[i] + 1 + M);
		}
	}
	int ret = 0;
	for (int i = 1; i <= M; i++) {
		if (i > 1) ans[i] = min(ans[i], ans[i - 1]);
		ret = max(ret, i * ans[i]);
	}
	cout << ret << '\n';
}

Compilation message

bomb.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 13 ms 26500 KB Output is correct
4 Correct 12 ms 26580 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Incorrect 1 ms 332 KB Output isn't correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 456 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 456 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1364 KB Output is correct
20 Correct 1 ms 1364 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 1236 KB Output is correct
23 Correct 2 ms 1492 KB Output is correct
24 Correct 1 ms 1236 KB Output is correct
25 Correct 1 ms 1492 KB Output is correct
26 Incorrect 1 ms 1492 KB Output isn't correct
27 Incorrect 4 ms 4700 KB Output isn't correct
28 Correct 5 ms 5212 KB Output is correct
29 Correct 6 ms 6488 KB Output is correct
30 Correct 8 ms 7896 KB Output is correct
31 Correct 7 ms 6356 KB Output is correct
32 Correct 7 ms 7124 KB Output is correct
33 Correct 9 ms 8416 KB Output is correct
34 Correct 5 ms 5332 KB Output is correct
35 Correct 10 ms 8432 KB Output is correct
36 Incorrect 9 ms 8404 KB Output isn't correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 234 ms 110624 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 30 ms 22240 KB Output is correct
41 Correct 1 ms 456 KB Output is correct
42 Correct 2 ms 1492 KB Output is correct
43 Correct 208 ms 110868 KB Output is correct
44 Correct 9 ms 8404 KB Output is correct
45 Correct 224 ms 110544 KB Output is correct
46 Correct 216 ms 110640 KB Output is correct
47 Correct 193 ms 110544 KB Output is correct
48 Correct 185 ms 110592 KB Output is correct
49 Incorrect 197 ms 110628 KB Output isn't correct
50 Correct 217 ms 110636 KB Output is correct
51 Correct 186 ms 110628 KB Output is correct
52 Correct 191 ms 110564 KB Output is correct
53 Correct 217 ms 110640 KB Output is correct
54 Correct 186 ms 110552 KB Output is correct
55 Correct 184 ms 110616 KB Output is correct
56 Correct 217 ms 110516 KB Output is correct
57 Correct 189 ms 110540 KB Output is correct
58 Correct 192 ms 110676 KB Output is correct
59 Correct 192 ms 110648 KB Output is correct
60 Incorrect 223 ms 110568 KB Output isn't correct
61 Incorrect 218 ms 110720 KB Output isn't correct
62 Incorrect 195 ms 110628 KB Output isn't correct
63 Incorrect 193 ms 110540 KB Output isn't correct
64 Incorrect 197 ms 110732 KB Output isn't correct
65 Correct 218 ms 110736 KB Output is correct
66 Correct 200 ms 110524 KB Output is correct
67 Correct 203 ms 110540 KB Output is correct
68 Correct 198 ms 110628 KB Output is correct
69 Correct 201 ms 110520 KB Output is correct
70 Correct 136 ms 87512 KB Output is correct
71 Correct 195 ms 110576 KB Output is correct
72 Correct 199 ms 110508 KB Output is correct
73 Correct 190 ms 110552 KB Output is correct
74 Correct 197 ms 110616 KB Output is correct
75 Correct 200 ms 110508 KB Output is correct
76 Correct 181 ms 110496 KB Output is correct
77 Correct 194 ms 110596 KB Output is correct
78 Correct 220 ms 110512 KB Output is correct
79 Correct 191 ms 110544 KB Output is correct
80 Correct 200 ms 110600 KB Output is correct
81 Correct 190 ms 110616 KB Output is correct
82 Correct 186 ms 110504 KB Output is correct
83 Correct 210 ms 110588 KB Output is correct
84 Correct 185 ms 110576 KB Output is correct
85 Correct 212 ms 110516 KB Output is correct
86 Correct 212 ms 110520 KB Output is correct
87 Correct 192 ms 110580 KB Output is correct
88 Correct 189 ms 110508 KB Output is correct
89 Correct 187 ms 110560 KB Output is correct
90 Correct 128 ms 87584 KB Output is correct
91 Correct 197 ms 110512 KB Output is correct
92 Correct 196 ms 110624 KB Output is correct
93 Correct 196 ms 110732 KB Output is correct
94 Correct 204 ms 110552 KB Output is correct
95 Correct 190 ms 110596 KB Output is correct
96 Correct 190 ms 110504 KB Output is correct
97 Correct 215 ms 110624 KB Output is correct
98 Correct 183 ms 110524 KB Output is correct
99 Correct 208 ms 110608 KB Output is correct
100 Correct 196 ms 110652 KB Output is correct