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>
#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... |