Submission #165609

# Submission time Handle Problem Language Result Execution time Memory
165609 2019-11-27T17:19:22 Z qkxwsm Bomb (IZhO17_bomb) C++14
4 / 100
317 ms 56704 KB
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 2513
#define INF 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N, M;
bitset<MAXN> grid[MAXN];
int up[MAXN][MAXN], dn[MAXN][MAXN];
int dp[MAXN];
int ans;
int width = INF;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(12);
	cerr << fixed << setprecision(4);
	cin >> N >> M;
	FOR(i, 0, N)
	{
		string temps; cin >> temps;
		FOR(j, 0, M)
		{
			grid[i][j] = (temps[j] == '1');
		}
	}
	//length of shortest vertical strip.
	FOR(i, 0, N + 1)
	{
		dp[i] = INF;
	}
	FOR(i, 0, M)
	{
		int sum = 0;
		FOR(j, 0, N)
		{
			if (grid[j][i])
			{
				sum++;
			}
			else
			{
				if (sum) ckmin(dp[1], sum);
				sum = 0;
			}
		}
		if (sum) ckmin(dp[1], sum);
	}
	FOR(i, 0, N)
	{
		int sum = 0;
		FOR(j, 0, M)
		{
			if (grid[i][j]) sum++;
			else sum = 0;
			if (sum) ckmin(width, sum);
		}
		if (sum) ckmin(width, sum);
	}
	// cerr << dp[1] << endl;
	FOR(j, 0, M)
	{
		FOR(i, 0, N)
		{
			if (!grid[i][j]) up[i][j] = i + 1;
			else up[i][j] = (i == 0 ? 0 : up[i - 1][j]);
		}
		FORD(i, N, 0)
		{
			if (!grid[i][j]) dn[i][j] = i - 1;
			else dn[i][j] = (i == N - 1 ? N - 1 : dn[i + 1][j]);
		}
	}
	// FOR(i, 0, N)
	// {
	// 	FOR(j, 0, M)
	// 	{
	// 		cerr << dn[i][j] << ' ';
	// 	}
	// 	cerr << endl;
	// }
	FOR(i, 0, N)
	{
		int sum = 0; pii bound = {0, M - 1};
		FOR(j, 0, M)
		{
			if (grid[i][j])
			{
				sum++;
				ckmin(bound.se, dn[i][j]);
				ckmax(bound.fi, up[i][j]);
			}
			else
			{
				sum = 0;
				bound = {0, M - 1};
			}
			if (sum > 1) ckmin(dp[sum], bound.se - bound.fi + 1);
			// cerr << sum << ',' << bound.se - bound.fi + 1 << ' ';
		}
		// cerr << endl;
	}
	FOR(i, 0, N)
	{
		int sum = 0; pii bound = {0, M - 1};
		FORD(j, M, 0)
		{
			if (grid[i][j])
			{
				sum++;
				ckmin(bound.se, dn[i][j]);
				ckmax(bound.fi, up[i][j]);
			}
			else
			{
				sum = 0;
				bound = {0, M - 1};
			}
			if (sum > 1) ckmin(dp[sum], bound.se - bound.fi + 1);
			// cerr << sum << ',' << bound.se - bound.fi + 1 << ' ';
		}
		// cerr << endl;
	}
	FOR(i, 1, width + 1)
	{
		ckmin(dp[i], dp[1]);
		ckmax(ans, dp[i] * i);
		// cerr << dp[i] << endl;
	}
	cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 19 ms 21240 KB Output is correct
4 Correct 22 ms 21240 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Incorrect 2 ms 504 KB Output isn't correct
9 Incorrect 2 ms 504 KB Output isn't correct
10 Incorrect 2 ms 420 KB Output isn't correct
11 Incorrect 2 ms 504 KB Output isn't correct
12 Correct 2 ms 504 KB Output is correct
13 Incorrect 2 ms 504 KB Output isn't correct
14 Incorrect 2 ms 504 KB Output isn't correct
15 Incorrect 2 ms 504 KB Output isn't correct
16 Incorrect 2 ms 508 KB Output isn't correct
17 Incorrect 3 ms 1016 KB Output isn't correct
18 Incorrect 3 ms 1016 KB Output isn't correct
19 Incorrect 3 ms 1272 KB Output isn't correct
20 Incorrect 3 ms 1144 KB Output isn't correct
21 Incorrect 3 ms 888 KB Output isn't correct
22 Incorrect 3 ms 1068 KB Output isn't correct
23 Incorrect 3 ms 1272 KB Output isn't correct
24 Incorrect 3 ms 1144 KB Output isn't correct
25 Incorrect 24 ms 1272 KB Output isn't correct
26 Incorrect 3 ms 1324 KB Output isn't correct
27 Incorrect 6 ms 3448 KB Output isn't correct
28 Incorrect 7 ms 3832 KB Output isn't correct
29 Incorrect 8 ms 4728 KB Output isn't correct
30 Incorrect 10 ms 5628 KB Output isn't correct
31 Incorrect 8 ms 4472 KB Output isn't correct
32 Incorrect 9 ms 5124 KB Output isn't correct
33 Incorrect 11 ms 5880 KB Output isn't correct
34 Incorrect 7 ms 4088 KB Output isn't correct
35 Incorrect 10 ms 5880 KB Output isn't correct
36 Incorrect 11 ms 5880 KB Output isn't correct
37 Incorrect 3 ms 504 KB Output isn't correct
38 Incorrect 309 ms 56528 KB Output isn't correct
39 Incorrect 2 ms 504 KB Output isn't correct
40 Incorrect 33 ms 14428 KB Output isn't correct
41 Incorrect 2 ms 504 KB Output isn't correct
42 Incorrect 3 ms 1272 KB Output isn't correct
43 Incorrect 308 ms 56504 KB Output isn't correct
44 Incorrect 10 ms 5880 KB Output isn't correct
45 Incorrect 300 ms 56600 KB Output isn't correct
46 Incorrect 307 ms 56500 KB Output isn't correct
47 Incorrect 305 ms 56568 KB Output isn't correct
48 Incorrect 309 ms 56560 KB Output isn't correct
49 Incorrect 311 ms 56568 KB Output isn't correct
50 Incorrect 299 ms 56572 KB Output isn't correct
51 Incorrect 303 ms 56576 KB Output isn't correct
52 Incorrect 307 ms 56704 KB Output isn't correct
53 Incorrect 302 ms 56592 KB Output isn't correct
54 Incorrect 302 ms 56440 KB Output isn't correct
55 Incorrect 298 ms 56396 KB Output isn't correct
56 Incorrect 311 ms 56440 KB Output isn't correct
57 Incorrect 292 ms 56596 KB Output isn't correct
58 Incorrect 292 ms 56496 KB Output isn't correct
59 Incorrect 294 ms 56552 KB Output isn't correct
60 Incorrect 296 ms 56648 KB Output isn't correct
61 Incorrect 305 ms 56420 KB Output isn't correct
62 Incorrect 311 ms 56436 KB Output isn't correct
63 Incorrect 309 ms 56568 KB Output isn't correct
64 Incorrect 308 ms 56548 KB Output isn't correct
65 Incorrect 300 ms 56504 KB Output isn't correct
66 Incorrect 299 ms 56440 KB Output isn't correct
67 Incorrect 302 ms 56496 KB Output isn't correct
68 Incorrect 300 ms 56568 KB Output isn't correct
69 Incorrect 293 ms 56592 KB Output isn't correct
70 Incorrect 184 ms 44280 KB Output isn't correct
71 Incorrect 295 ms 56556 KB Output isn't correct
72 Incorrect 297 ms 56456 KB Output isn't correct
73 Incorrect 299 ms 56568 KB Output isn't correct
74 Incorrect 303 ms 56568 KB Output isn't correct
75 Incorrect 291 ms 56416 KB Output isn't correct
76 Incorrect 317 ms 56564 KB Output isn't correct
77 Incorrect 299 ms 56452 KB Output isn't correct
78 Incorrect 290 ms 56584 KB Output isn't correct
79 Incorrect 287 ms 56636 KB Output isn't correct
80 Incorrect 284 ms 56412 KB Output isn't correct
81 Incorrect 311 ms 56440 KB Output isn't correct
82 Incorrect 294 ms 56612 KB Output isn't correct
83 Incorrect 300 ms 56468 KB Output isn't correct
84 Incorrect 289 ms 56556 KB Output isn't correct
85 Incorrect 293 ms 56568 KB Output isn't correct
86 Incorrect 305 ms 56568 KB Output isn't correct
87 Incorrect 292 ms 56628 KB Output isn't correct
88 Incorrect 293 ms 56408 KB Output isn't correct
89 Incorrect 300 ms 56568 KB Output isn't correct
90 Incorrect 205 ms 44324 KB Output isn't correct
91 Incorrect 305 ms 56412 KB Output isn't correct
92 Incorrect 293 ms 56572 KB Output isn't correct
93 Incorrect 303 ms 56620 KB Output isn't correct
94 Incorrect 295 ms 56440 KB Output isn't correct
95 Incorrect 294 ms 56648 KB Output isn't correct
96 Incorrect 296 ms 56568 KB Output isn't correct
97 Incorrect 305 ms 56696 KB Output isn't correct
98 Incorrect 291 ms 56540 KB Output isn't correct
99 Incorrect 292 ms 56440 KB Output isn't correct
100 Incorrect 308 ms 56568 KB Output isn't correct