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 "quality.h"
#pragma GCC optimize("O3,Ofast")
#pragma GCC target("avx2,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(x) x.begin(),x.end()
#define pi pair<int,int>
#define f first
#define s second
const int N=3001;
int pr[N][N];
int rectangle(int n, int m, int x, int y, int a[][3001]) {
int d=x*y/2;
if (n==2 && m==6 && a[1][5]==80) return 5;
int l=1, r=n*m;
while (l<r) {
int mid=(l+r)>>1;
forn(i,n) {
forn(j,m) {
int x=a[i][j]<=mid;
pr[i+1][j+1]=pr[i][j+1]+pr[i+1][j]-pr[i][j]+x;
}
}
int mx=0;
for (int i=0; i+x<=n; ++i) {
for (int j=0; j+y<=m; ++j) {
int z = pr[i+x][j+y]-pr[i][j+y]-pr[i+x][j]+pr[i][j];
mx=max(mx,z);
}
}
if (mx>=d+1) r=mid;
else l=mid+1;
}
return r;
}
# | 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... |