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"
const int N = 3010;
int pom[N][N], b[N][N];
bool check (int x, int n, int m, int h, int w, int a[N][N]) {
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
pom[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] <= x) pom[i][j] = 1;
else pom[i][j] = 0;
pom[i][j] = pom[i][j]+pom[i-1][j]+pom[i][j-1]-pom[i-1][j-1];
}
}
/*for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cout << pom[i][j] << " ";
}
cout << endl;
}*/
for (int i = h; i <= n; i++) {
for (int j = w; j <= m; j++) {
int val = pom[i][j]-pom[i-h][j]-pom[i][j-w]+pom[i-h][j-w];
if (val >= (h*w+1)/2) return true;
}
}
return false;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
int lo = 1, hi = R*C, mid;
for (int i = 0; i < R; i++) {
for (int j = 0; j < C; j++) {
b[i+1][j+1] = Q[i][j];
}
}
while (lo < hi) {
mid = (lo+hi)/2;
if (check(mid, R, C, H, W, b)) {
hi = mid;
}
else {
lo = mid+1;
}
}
return lo;
}
# | 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... |