이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3001;
int pref[MAXN][MAXN];
bool check(int x, int n, int m, int h, int w, int a[MAXN][MAXN]){
int px, py;
for (int i = 0; i <= max(n, m); ++i){
pref[0][i] = 0; pref[i][0] = 0;
}
for (int i = 1; i <= n; ++i){
for (int j = 1; j <= m; ++j){
pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1];
if (a[i - 1][j - 1] < x)
--pref[i][j];
else if (a[i - 1][j - 1] > x)
++pref[i][j];
else{
px = i; py = j;
}
}
}
for (int i = 1; i <= n - h + 1; ++i){
for (int j = 1; j <= m - w + 1; ++j){
if (pref[i + h - 1][j + w - 1] - pref[i - 1][j + w - 1] - pref[i + h - 1][j - 1] + pref[i - 1][j - 1] <= 0 && (px >= i && px <= i + h - 1 && py >= j && py <= j + w - 1))
return 1;
}
}
return 0;
}
int bins(int l, int r, int n, int m, int h, int w, int a[MAXN][MAXN]){
int mid = (l + r - 1) / 2;
if (l == r)
return l;
else if (check(mid, n, m, h, w, a))
return bins(l, mid, n, m, h, w, a);
return bins(mid + 1, r, n, m, h, w, a);
}
int rectangle(int R, int C, int H, int W, int Q[MAXN][MAXN]){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
return bins(1, R * C, R, C, H, W, Q);
}
컴파일 시 표준 에러 (stderr) 메시지
quality.cpp: In function 'bool check(int, int, int, int, int, int (*)[3001])':
quality.cpp:27:162: warning: 'py' may be used uninitialized in this function [-Wmaybe-uninitialized]
27 | if (pref[i + h - 1][j + w - 1] - pref[i - 1][j + w - 1] - pref[i + h - 1][j - 1] + pref[i - 1][j - 1] <= 0 && (px >= i && px <= i + h - 1 && py >= j && py <= j + w - 1))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
quality.cpp:27:120: warning: 'px' may be used uninitialized in this function [-Wmaybe-uninitialized]
27 | if (pref[i + h - 1][j + w - 1] - pref[i - 1][j + w - 1] - pref[i + h - 1][j - 1] + pref[i - 1][j - 1] <= 0 && (px >= i && px <= i + h - 1 && py >= j && py <= j + w - 1))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |