# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47532 | 2018-05-05T02:49:52 Z | aome | Luxury burrow (IZhO13_burrow) | C++17 | 650 ms | 58532 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1005; int n, m, K; int res; int l[N], r[N]; int a[N][N]; int b[N][N]; int f[N][N]; void solve(int x) { for (int i = 1; i <= m; ++i) { l[i] = i; while (l[i] > 1 && f[x][l[i] - 1] >= f[x][i]) l[i] = l[l[i] - 1]; } for (int i = m; i >= 1; --i) { r[i] = i; while (r[i] < m && f[x][r[i] + 1] >= f[x][i]) r[i] = r[r[i] + 1]; } for (int i = 1; i <= m; ++i) res = max(res, (r[i] - l[i] + 1) * f[x][i]); } void calc(int x) { for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) b[i][j] = a[i][j] >= x; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { if (b[i][j]) f[i][j] = f[i - 1][j] + 1; else f[i][j] = 0; } res = 0; for (int i = 1; i <= n; ++i) solve(i); } int main() { scanf("%d %d %d", &n, &m, &K); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { scanf("%d", &a[i][j]); } } int l = 1, r = 1e9; while (l < r) { int mid = (l + r + 1) >> 1; calc(mid); if (res >= K) l = mid; else r = mid - 1; } calc(l); cout << l << ' ' << res << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 520 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 740 KB | Output is correct |
5 | Correct | 3 ms | 896 KB | Output is correct |
6 | Correct | 3 ms | 1160 KB | Output is correct |
7 | Correct | 2 ms | 1160 KB | Output is correct |
8 | Correct | 10 ms | 1980 KB | Output is correct |
9 | Correct | 12 ms | 3196 KB | Output is correct |
10 | Correct | 30 ms | 3572 KB | Output is correct |
11 | Correct | 58 ms | 4652 KB | Output is correct |
12 | Correct | 30 ms | 7836 KB | Output is correct |
13 | Correct | 38 ms | 7836 KB | Output is correct |
14 | Correct | 111 ms | 7836 KB | Output is correct |
15 | Correct | 86 ms | 8228 KB | Output is correct |
16 | Correct | 101 ms | 9456 KB | Output is correct |
17 | Correct | 91 ms | 10992 KB | Output is correct |
18 | Correct | 265 ms | 15092 KB | Output is correct |
19 | Correct | 263 ms | 18112 KB | Output is correct |
20 | Correct | 587 ms | 24924 KB | Output is correct |
21 | Correct | 506 ms | 32400 KB | Output is correct |
22 | Correct | 648 ms | 43124 KB | Output is correct |
23 | Correct | 650 ms | 52936 KB | Output is correct |
24 | Correct | 393 ms | 55016 KB | Output is correct |
25 | Correct | 401 ms | 58532 KB | Output is correct |