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"
using namespace std;
bool Teste(int x, vector<vector<int>> &Q, int R, int C, int H, int W)
{
vector<vector<int>> S(R+1, vector<int>(C+1));
for (int i = 1; i <= R; i++)
for (int j = 1; j <= C; j++)
S[i][j] = (int)(Q[i][j] <= x) + S[i][j-1] + S[i-1][j] - S[i-1][j-1];
for (int i = H; i <= R; i++)
for (int j = W; j <= C; j++)
if (S[i][j] - S[i][j-W] - S[i-H][j] + S[i-H][j-W] >= (H*W + 1)/2)
return true;
return false;
}
int rectangle(int R, int C, int H, int W, int _Q[3001][3001])
{
vector<vector<int>> Q(R+1, vector<int>(C+1));
for (int i = 0; i < R; i++)
for (int j = 0; j < C; j++)
Q[i+1][j+1] = _Q[i][j];
int ini = 1, fim = R*C;
while (ini < fim)
{
int m = (ini + fim) >> 1;
if (Teste(m, Q, R, C, H, W)) fim = m;
else ini = m+1;
}
return fim;
}
# | 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... |