이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
int acum[3005][3005];
int query(int x, int y, int _x, int _y){
int suma = 0;
suma = acum[_x][_y] + acum[x - 1][y - 1];
suma-= acum[_x][y - 1];
return suma-= acum[x - 1][_y];
}
bool probar(int cant, int n, int m, int x, int y){
for(int i = x; i <= n; ++i){
for(int j = y; j <= m; ++j){
int aux = query(i - x + 1, j - y + 1, i, j);
if(aux <= cant) return true;
}
}
return false;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
int inf = 1, sup = R * C, medio, ans = 1, busco = H * W;
busco/=2;
while(inf <= sup){
medio = (inf + sup) / 2;
for(int i = 0; i < R; ++i){
for(int j = 0; j < C; ++j){
if(Q[i][j] > medio) acum[i + 1][j + 1] = 1;
else acum[i + 1][j + 1] = 0;
acum[i + 1][j + 1] += acum[i + 1][j] + acum[i][j + 1] - acum[i][j];
}
}
if(probar(busco, R, C, H, W)){
ans = medio;
sup = medio - 1;
}else{
inf = medio + 1;
}
}
return ans;
}
# | 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... |