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 <stdlib.h>
//#include "quality.h"
using namespace std;
const int mn=3001;
int f(set<int>s)
{
int sredina=s.size()/2;
set<int>::iterator it=s.begin();
int sta=0;
while(it!=s.end())
{
if(sta==sredina) return *it;
sta++;
it++;
}
return 1;
}
int rectangle1(int r,int c,int h,int w,int q[mn][mn])
{
int mn=r*c;
for(int i=0;i<=r-h;i++)
{
set<int> s;
for(int j=i;j<i+h;j++)
{
for(int k=0;k<w;k++)
{
s.insert(q[j][k]);
}
}
mn=min(f(s),mn);
for(int j=1;j<=c-w;j++)
{
for(int k=i;k<i+h;k++) s.erase(q[k][j-1]);
for(int k=i;k<i+h;k++) s.insert(q[k][j+w-1]);
mn=min(f(s),mn);
}
}
return mn;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
return rectangle1(R,C,H,W,Q);
}
/*
static int R,C,H,W,Q[3001][3001],i,j,ans;
int main(){
scanf("%d%d%d%d",&R,&C,&H,&W);
for (i=0;i<R;i++) for (j=0;j<C;j++) scanf("%d",&Q[i][j]);
ans = rectangle(R,C,H,W,Q);
printf("%d\n",ans);
return 0;
}*/
# | 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... |