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"
int rectangle(int n,int m,int h,int w,int a[3001][3001])
{
int l=0,r=n*m;
int s[n+1][m+1];
memset(s,0,sizeof(s));
while(l<r-1)
{
int lim=(l+r)/2;
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(a[i-1][j-1]<=lim);
bool ok=0;
for(int i=h;i<=n;i++) for(int j=w;j<=m;j++) ok|=(s[i][j]-s[i-h][j]-s[i][j-w]+s[i-h][j-w]>=(h*w+1)/2);
if(ok) r=lim;
else l=lim;
}
return r;
}
# | 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... |