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<bits/stdc++.h>
#include "quality.h"
using namespace std;
const int MAXN=3005;
int n,m;
int h,w;
int half;
int pref[MAXN][MAXN];
bool check(int x,int q[][3001])
{
pref[0][0]=0;
int numX=-1, numY=-1;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(q[i][j]==x) numX=i, numY=j;
if(i>0 && j>0) pref[i][j]=pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1];
else if(i>0) pref[i][j]=pref[i-1][j];
else if(j>0) pref[i][j]=pref[i][j-1];
if(q[i][j]<x) pref[i][j]++;
if(i>=h-1 && j>=w-1)
{
int a1=0,a2=0,b=0;
if(i>=h) a1=pref[i-h][j];
if(j>=w) a2=pref[i][j-w];
if(i>=h && j>=w) b=pref[i-h][j-w];
if(pref[i][j]-a1-a2+b>=half && (i-h<numX && numX<=i && j-w<=numY && numY<=j)) return 1;
}
}
}
return 0;
}
int rectangle(int R,int C,int H,int W,int q[3001][3001])
{
n=R, m=C;
h=H, w=W;
half=h*w/2;
int l=1,r=n*m;
while(l<r)
{
int mid=(l+r)/2;
if(check(mid,q)) r=mid;
else l=mid+1;
}
return l;
}
# | 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... |