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;
const int mxn=3e3+5;
int arr[mxn][mxn],dp[mxn][mxn];
int query(int i,int j,int x,int y){
return dp[i][j]-dp[i-x][j]-dp[i][j-y]+dp[i-x][j-y];
}
int rectangle(int n, int m, int x, int y, int Q[3001][3001]) {
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
arr[i][j]=Q[i-1][j-1];
}
}
int l=1,r=n*m;
while(l<=r){
int mm=(l+r)/2;
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(arr[i][j]<=mm){
dp[i][j]=1;
}
else if(arr[i][j]>mm){
dp[i][j]=0;
}
dp[i][j]+=dp[i-1][j];
dp[i][j]+=dp[i][j-1];
dp[i][j]-=dp[i-1][j-1];
if(i>=x&&j>=y){
if(query(i,j,x,y)>=(x*y+1)/2){
ans=1;
}
}
}
}
if(ans){
r=mm-1;
}
else{
l=mm+1;
}
}
return r+1;
}
# | 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... |