# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47532 | aome | Luxury burrow (IZhO13_burrow) | C++17 | 650 ms | 58532 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |