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 "grader.h"
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, n) for (int i = x; i <= n; i++)
#define mem(a, x) memset(a, x, sizeof(a))
bool check(int R, int C, int H, int W, int Q[3001][3001], int median) {
int ps[3001][3001];
mem(ps, 0);
FOR(i, 1, R) {
FOR(j, 1, C) {
if (Q[i - 1][j - 1] <= median) {
ps[i][j] = 1;
} else {
ps[i][j] = -1;
}
}
}
FOR(i, 1, R) {
FOR(j, 1, C) {
ps[i][j] += ps[i][j - 1] + ps[i - 1][j] - ps[i - 1][j - 1];
}
}
FOR(i, H, R) {
FOR(j, W, C) {
if (ps[i][j] - ps[i - H][j] - ps[i][j - W] + ps[i - H][j - W] > 0) {
return true;
}
}
}
return false;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
int ans = -1;
int l = 1, r = R * C;
while (l <= r) {
int m = (l + r) / 2;
if (check(R, C, H, W, Q, m)) {
ans = m;
r = m - 1;
} else {
l = m + 1;
}
}
return ans;
}
# | 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... |