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>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int sm[3002][3002];
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
auto possible = [&](int x) {
RE(i,R+1) RE(j,C+1) sm[i][j] = 0;
RE(i,R) RE(j,C) if(Q[i][j]>x) sm[i+1][j+1]++;
RE(i,R+1) RE(j,C+1) {
if(i ) sm[i][j] += sm[i-1][j ];
if( j) sm[i][j] += sm[i ][j-1];
if(i&&j) sm[i][j] -= sm[i-1][j-1];
}
RE(i,R-H+1) RE(j,C-W+1) if(sm[i+H][j+W] - sm[i+H][j] - sm[i][j+W] + sm[i][j] <= (W*H)/2) return true;
return false;
};
int lb=1, ub=R*C;
while(lb != ub) {
int mid=(lb+ub)/2;
if(possible(mid)) ub=mid;
else lb=mid+1;
}
return lb;
}
# | 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... |