이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "quality.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) x.begin(),x.end();
using ll=long long;
const ll INF=1LL<<60;
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
vector<vector<int>> cum(R+1,vector<int>(C+1,0));
int ok=R*C,ng=0;
while(ok-ng>1){
int mid=(ok+ng)/2;
rep(i,R+1){
cum[i][0]=0;
}
rep(i,C+1){
cum[0][i]=0;
}
rep(i,R){
rep(j,C){
cum[i+1][j+1]=cum[i+1][j]+cum[i][j+1]-cum[i][j];
if(Q[i][j]<=mid)cum[i+1][j+1]++;
}
}
bool can=false;
rep(i,R-H+1){
rep(j,C-W+1){
int val=cum[i+H][j+W]-cum[i+H][j]-cum[i][j+W]+cum[i][j];
if(val>=H*W-val)can=true;
}
}
if(can)ok=mid;
else ng=mid;
}
return ok;
}
//g++ -o quality -O2 quality.cpp grader.cpp
# | 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... |