This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int r,c,h,w,num[3005][3005],pre[3005][3005];
bool check(int v){
int i,j;
for(i=0;i<r;i++){
for(j=0;j<c;j++){
if(num[i][j]<v)
pre[i][j]=1;
else if(num[i][j]==v)
pre[i][j]=0;
else
pre[i][j]=-1;
}
}
for(i=0;i<r;i++)
for(j=0;j<c;j++)
pre[i][j]+=(j?pre[i][j-1]:0)+(i?pre[i-1][j]:0)-((i&&j)?pre[i-1][j-1]:0);
for(i=0;i<=r-h;i++)
for(j=0;j<=c-w;j++)
if(pre[i+h-1][j+w-1]+((i&&j)?pre[i-1][j-1]:0)-(j?pre[i+h-1][j-1]:0)-(i?pre[i-1][j+w-1]:0)>=0)
return 1;
return 0;
}
int rectangle(int R,int C,int H,int W,int Q[3001][3001]){
r=R;
c=C;
h=H;
w=W;
int i,j,right=r*c+1,left=0;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
num[i][j]=Q[i][j];
while(right-left>1){
int mid=(right+left)>>1;
if(check(mid))
right=mid;
else
left=mid;
}
return right;
}
# | 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... |