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 "quality.h"
#include <bits/stdc++.h>
bool f(int r, int c, int h, int w, int q[3001][3001], int mid) {
int g[3001][3001];
for (int i = 0; i <= r; i++)
for (int j = 0; j <= c; j++)
g[i][j] = 0;
for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++)
g[i + 1][j + 1] = g[i][j + 1] + g[i + 1][j] - g[i][j] + (q[i][j] <= mid);
for (int i = h; i <= r; i++)
for (int j = w; j <= c; j++)
if (g[i][j] - g[i - h][j] - g[i][j - w] + g[i - h][j - w] > h * w / 2) return true;
return false;
}
int rectangle(int r, int c, int h, int w, int q[3001][3001]) {
int L = 0, R = r * c;
while (R - L - 1) {
int mid = (L + R) >> 1;
if (f(r, c, h, w, q, mid)) R = mid;
else L = mid;
}
return R;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |