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"
#include <bits/stdc++.h>
// #include <stdio.h>
// #include <stdlib.h>
// #include "quality.h"
using namespace std;
typedef long long ll;
// static int R,C,H,W,Q[3001][3001],i,j,ans;
ll lo, hi, mid, simpan;
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
lo = 1, hi = R * C, mid, simpan;
while (lo <= hi){
mid = (lo + hi) / 2;
ll grid[3001][3001];
ll pref[3005][3005];
memset(pref, 0, sizeof(pref));
cout<<mid<<endl;
for (int i = 1; i <= R; i++){
for (int j = 1; j <= C; j++){
if (Q[i - 1][j - 1] == mid){
grid[i][j] = 0;
}
else if (Q[i - 1][j - 1] > mid){
grid[i][j] = 1;
}
else{
grid[i][j] = -1;
}
cout << grid[i][j]<<" ";
}
cout<<endl;
}
for (int i = 1; i <= R; i++){
for (int j = 1; j <= C; j++){
if (i == 1 && j == 1){
pref[i][j] = grid[i][j];
continue;
}
pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + grid[i][j];
}
}
ll x = 0;
for (int i = 1; i <= R - H + 1; i++){
if (x == 1) break;
for (int j = 1; j <= C - W + 1; j++){
ll p = i + H - 1, q = j + W - 1;
ll u = pref[p][q] - pref[p][j - 1] - pref[i - 1][q] + pref[i - 1][j - 1];
if (u >= 0){
x = 1;
}
}
}
if (x == 0){
hi = mid - 1;
}
else{
lo = mid + 1;
simpan = mid;
}
}
return simpan;
}
// 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;
// }
Compilation message (stderr)
quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:11:30: warning: right operand of comma operator has no effect [-Wunused-value]
11 | lo = 1, hi = R * C, mid, simpan;
| ^~~~~~
quality.cpp:11:36: warning: right operand of comma operator has no effect [-Wunused-value]
11 | lo = 1, hi = R * C, mid, simpan;
| ^
# | 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... |