이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "quality.h"
#define DIM 3001
using namespace std;
int sp[DIM][DIM],v[DIM*DIM];
int verif (int n, int m, int h, int w, int a[3001][3001], int val){
int i,j;
for (i=1;i<=n;i++)
for (j=1;j<=m;j++)
sp[i][j] = 0;
for (i=1;i<=n;i++)
for (j=1;j<=m;j++){
sp[i][j] = sp[i-1][j] + sp[i][j-1] - sp[i-1][j-1];
if (a[i-1][j-1] <= val)
sp[i][j]++;
}
for (i=1;i<=n-h+1;i++)
for (j=1;j<=m-w+1;j++){
int sum = sp[i+h-1][j+w-1] - sp[i+h-1][j-1] - sp[i-1][j+w-1] + sp[i-1][j-1];
if (sum >= h*w / 2 + 1)
return 1;
}
return 0;
}
int rectangle (int n, int m, int h, int w, int a[3001][3001]){
int k = 0;
for (int i=0;i<n;i++)
for (int j=0;j<m;j++)
v[++k] = a[i][j];
sort (v+1,v+k+1);
int st = 1, dr = n*m, sol = 0;
while (st <= dr){
int mid = (st+dr)>>1;
if (verif(n,m,h,w,a,v[mid])){
sol = v[mid];
dr = mid-1;
} else st = mid+1;
}
return sol;
}
# | 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... |