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"
int sum[3005][3005];
int get_sum(int x1,int y1,int x2,int y2) {
int ret=sum[x2][y2];
if(x1) ret-=sum[x1-1][y2];
if(y1) ret-=sum[x2][y1-1];
if(x1 && y1) ret+=sum[x1-1][y1-1];
return ret;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
int r=R,c=C,h=H,w=W;
int lo=1,hi=r*c;
while(lo<hi) {
int mid=(lo+hi)/2;
int s=0,cnt=0;
for(int i=0;i<r;i++) {
s=0;
for(int j=0;j<c;j++) {
if(Q[i][j]<=mid) s+=1;
else s-=1;
sum[i][j]=s;
if(i) sum[i][j]+=sum[i-1][j];
}
}
for(int i=0;i+h-1<r;i++) {
for(int j=0;j+w-1<c;j++) {
if(get_sum(i,j,i+h-1,j+w-1)>0) cnt+=1;
}
}
if(cnt) 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... |