Submission #556156

# Submission time Handle Problem Language Result Execution time Memory
556156 2022-05-02T14:05:08 Z ngpin04 Bomb (IZhO17_bomb) C++14
22 / 100
338 ms 79256 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define TASK ""
#define ALL(x) (x).begin(), (x).end() 
using namespace std;
template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
	if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
	if (a < b) {a = b; return true;} return false;
}
const int N = 2505;
const int oo = 1e9;
const long long ooo = 1e18;
const int mod = 1e9 + 7; // 998244353;
const long double pi = acos(-1);

int up[N][N];
int dn[N][N];
int a[N][N];
int mx[N];
int n,m;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef ONLINE_JUDGE
	// freopen(TASK".inp","r",stdin);
	// freopen(TASK".out","w",stdout);
	#endif
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		string str; cin >> str;
		for (int j = 1; j <= m; j++)
			a[i][j] = str[j - 1] - '0';
	}	

	for (int j = 1; j <= m; j++) {
		for (int i = 1; i <= n; i++) 
			if (a[i][j])
				up[i][j] = up[i - 1][j] + 1;

		for (int i = n; i >= 1; i--)
			if (a[i][j])
				dn[i][j] = dn[i + 1][j] + 1;
	}

	for (int i = 1; i <= m; i++)
		mx[i] = oo;

	for (int i = 1; i <= n; i++) 
	for (int t = 0; t < 2; t++) {

		for (int j = 1; j <= m; j++) if (a[i][j]) {
			int k = j;
			while (a[i][k])
				k++;

			int f = oo, g = oo;
			for (int it = j; it < k; it++) {
				mini(f, up[i][it]);
				mini(g, dn[i][it]);

				mini(mx[it - j + 1], f + g - 1);
			}

			mini(mx[k - j + 1], 0);
			j = k;
		}

		reverse(a[i] + 1, a[i] + m + 1);
		reverse(dn[i] + 1, dn[i] + m + 1);
		reverse(up[i], up[i] + m + 1);
	}
	
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		if (mx[i] == 0)
			break;
		maxi(ans, i * mx[i]);
	}

	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Incorrect 1 ms 460 KB Output isn't correct
3 Incorrect 11 ms 30408 KB Output isn't correct
4 Incorrect 15 ms 30368 KB Output isn't correct
5 Incorrect 1 ms 328 KB Output isn't correct
6 Incorrect 1 ms 384 KB Output isn't correct
7 Incorrect 1 ms 332 KB Output isn't correct
8 Incorrect 1 ms 468 KB Output isn't correct
9 Incorrect 1 ms 468 KB Output isn't correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Incorrect 1 ms 468 KB Output isn't correct
13 Incorrect 1 ms 468 KB Output isn't correct
14 Incorrect 1 ms 468 KB Output isn't correct
15 Incorrect 1 ms 464 KB Output isn't correct
16 Correct 1 ms 468 KB Output is correct
17 Incorrect 1 ms 1108 KB Output isn't correct
18 Correct 1 ms 1236 KB Output is correct
19 Incorrect 1 ms 1488 KB Output isn't correct
20 Incorrect 1 ms 1492 KB Output isn't correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 1228 KB Output is correct
23 Incorrect 2 ms 1620 KB Output isn't correct
24 Incorrect 1 ms 1364 KB Output isn't correct
25 Incorrect 1 ms 1612 KB Output isn't correct
26 Incorrect 1 ms 1620 KB Output isn't correct
27 Incorrect 4 ms 4804 KB Output isn't correct
28 Incorrect 6 ms 5204 KB Output isn't correct
29 Incorrect 6 ms 6596 KB Output isn't correct
30 Incorrect 7 ms 8028 KB Output isn't correct
31 Correct 4 ms 6180 KB Output is correct
32 Incorrect 5 ms 7124 KB Output isn't correct
33 Incorrect 6 ms 8280 KB Output isn't correct
34 Incorrect 5 ms 5640 KB Output isn't correct
35 Incorrect 7 ms 8276 KB Output isn't correct
36 Incorrect 7 ms 8284 KB Output isn't correct
37 Incorrect 1 ms 468 KB Output isn't correct
38 Incorrect 274 ms 78960 KB Output isn't correct
39 Incorrect 1 ms 468 KB Output isn't correct
40 Incorrect 33 ms 20780 KB Output isn't correct
41 Incorrect 1 ms 468 KB Output isn't correct
42 Incorrect 2 ms 1620 KB Output isn't correct
43 Incorrect 265 ms 79056 KB Output isn't correct
44 Incorrect 7 ms 8276 KB Output isn't correct
45 Incorrect 228 ms 79044 KB Output isn't correct
46 Incorrect 235 ms 79084 KB Output isn't correct
47 Incorrect 237 ms 79136 KB Output isn't correct
48 Incorrect 246 ms 79080 KB Output isn't correct
49 Incorrect 301 ms 79172 KB Output isn't correct
50 Correct 264 ms 79056 KB Output is correct
51 Correct 224 ms 79176 KB Output is correct
52 Incorrect 234 ms 79072 KB Output isn't correct
53 Correct 234 ms 79060 KB Output is correct
54 Correct 180 ms 79112 KB Output is correct
55 Incorrect 195 ms 79068 KB Output isn't correct
56 Incorrect 307 ms 79072 KB Output isn't correct
57 Incorrect 186 ms 79020 KB Output isn't correct
58 Correct 226 ms 79168 KB Output is correct
59 Correct 197 ms 78976 KB Output is correct
60 Incorrect 249 ms 79016 KB Output isn't correct
61 Incorrect 313 ms 79036 KB Output isn't correct
62 Incorrect 322 ms 79064 KB Output isn't correct
63 Incorrect 322 ms 79084 KB Output isn't correct
64 Incorrect 192 ms 79068 KB Output isn't correct
65 Incorrect 223 ms 78988 KB Output isn't correct
66 Correct 237 ms 79044 KB Output is correct
67 Incorrect 262 ms 79084 KB Output isn't correct
68 Correct 271 ms 79072 KB Output is correct
69 Correct 186 ms 79052 KB Output is correct
70 Correct 135 ms 63176 KB Output is correct
71 Incorrect 190 ms 79200 KB Output isn't correct
72 Incorrect 200 ms 79204 KB Output isn't correct
73 Correct 213 ms 79200 KB Output is correct
74 Incorrect 214 ms 79092 KB Output isn't correct
75 Incorrect 226 ms 79120 KB Output isn't correct
76 Incorrect 219 ms 79184 KB Output isn't correct
77 Incorrect 201 ms 79256 KB Output isn't correct
78 Incorrect 200 ms 79108 KB Output isn't correct
79 Incorrect 156 ms 79108 KB Output isn't correct
80 Incorrect 145 ms 79188 KB Output isn't correct
81 Incorrect 161 ms 79176 KB Output isn't correct
82 Incorrect 205 ms 79152 KB Output isn't correct
83 Incorrect 245 ms 79188 KB Output isn't correct
84 Incorrect 149 ms 79180 KB Output isn't correct
85 Incorrect 196 ms 79048 KB Output isn't correct
86 Incorrect 308 ms 79052 KB Output isn't correct
87 Incorrect 201 ms 79088 KB Output isn't correct
88 Correct 206 ms 79084 KB Output is correct
89 Correct 242 ms 79004 KB Output is correct
90 Incorrect 128 ms 63072 KB Output isn't correct
91 Incorrect 217 ms 79060 KB Output isn't correct
92 Incorrect 234 ms 79108 KB Output isn't correct
93 Incorrect 315 ms 79108 KB Output isn't correct
94 Correct 246 ms 79156 KB Output is correct
95 Incorrect 209 ms 79188 KB Output isn't correct
96 Correct 199 ms 79052 KB Output is correct
97 Incorrect 338 ms 78976 KB Output isn't correct
98 Incorrect 209 ms 79080 KB Output isn't correct
99 Incorrect 233 ms 79152 KB Output isn't correct
100 Incorrect 300 ms 79072 KB Output isn't correct