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 <iostream>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <random>
#include <string>
#include <cassert>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include "quality.h"
using namespace std;
#define ll long long
#define f first
#define s second
int r, c, h, w, q[3001][3001], pref[3001][3001];
bool possible(int x) {
fill(&pref[0][0], &pref[0][0] + sizeof(pref) / sizeof(pref[0][0]), 0);
for (int i = 1; i <= r; i++) {
for (int j = 1; j <= c; j++) {
if (q[i][j] == x) {
} else if (q[i][j] > x) pref[i][j] = -1;
else pref[i][j] = 1;
pref[i][j] += pref[i - 1][j];
pref[i][j] += pref[i][j - 1];
pref[i][j] -= pref[i - 1][j - 1];
}
}
for (int i = h; i <= r; i++) {
for (int j = w; j <= c; j++) {
if (pref[i][j] - pref[i - h][j] - pref[i][j - w] + pref[i - h][j - w] >= 0) return true;
}
}
return false;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
r = R, c = C, h = H, w = W;
for (int i = 1; i <= R; i++) for (int j = 1; j <= C; j++) q[i][j] = Q[i - 1][j - 1];
int lft = 1, rht = R * C, ret = R * C;
while (lft <= rht) {
int mid = (lft + rht) / 2;
if (possible(mid)) {
rht = mid - 1;
ret = mid;
} else lft = mid + 1;
}
return ret;
}
# | 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... |