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>
using namespace std;
int rectangle(int N, int M, int y, int x, int q[3001][3001]){
int left=1, right=N*M;
while(left<right){
int m=(left+right)/2;
auto ok=[&](int cost){
vector<vector<int>> s(N+1,vector<int>(M+1));
for(int i = 1; i<=N;++i)
for(int j=1;j<=M;++j)
s[i][j]=((q[i-1][j-1]<cost)?-1:(q[i-1][j-1]==cost?0:1))+s[i-1][j]+s[i][j-1]-s[i-1][j-1];
for(int i=1;i<=N-y+1;++i)
for(int j=1;j<=M-x+1;++j){
int ii=i+y-1, jj=j+x-1;
if(s[ii][jj]-s[i-1][jj]-s[ii][j-1]+s[i-1][j-1]<=0)
return 1;
}
return 0;
};
if(ok(m))
right=m;
else
left=m+1;
}
return left;
}
# | 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... |