이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "quality.h"
//#include "grader.cpp"
int a[3001][3001],pre[3001][3001];
int n,m,x,y;
int sum(int x1,int x2,int y1,int y2){
int sum1=pre[x2][y2];
int sum2=(y1?pre[x2][y1-1]:0);
int sum3=(x1?pre[x1-1][y2]:0);
int sum4=(x1&&y1?pre[x1-1][y1-1]:0);
return sum1-sum2-sum3+sum4;
}
bool f(int X){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
pre[i][j]=(i?pre[i-1][j]:0)+(j?pre[i][j-1]:0)-(i&&j?pre[i-1][j-1]:0)+(a[i][j]<=X?1:-1);
}
}
for(int i=x-1;i<n;i++){
for(int j=y-1;j<m;j++){
if(sum(i-x+1,i,j-y+1,j)>=1){
std::cout<<sum(i-x+1,i,j-y+1,j)<<" "<<i<<" "<<j<<"\n";
return 1;
}
}
}
return 0;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
n=R;m=C;x=H;y=W;
for(int i=0;i<n;i++)for(int j=0;j<m;j++)a[i][j]=Q[i][j];
int l=1,r=n*m,res=INT_MAX;
while(l<=r){
int md=(l+1)>>1;
if(f(md))r=(res=md)-1;
else l=md+1;
}
return res;
}
# | 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... |