Submission #950875

# Submission time Handle Problem Language Result Execution time Memory
950875 2024-03-20T21:03:46 Z Yell0 Quality Of Living (IOI10_quality) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
const int MN=3002;
int pfs[MN][MN], q[MN][MN];

int qry(int r1, int c1, int r2, int c2) {
  int ans = pfs[r2][c2];
  if(r1 > 0) ans -= pfs[r1-1][c2];
  if(c1 > 0) ans -= pfs[r2][c1-1];
  if(r1 > 0 && c1 > 0) ans += pfs[r1-1][c1-1];
  return ans;
}

int rectangle(int R, int C, int H, int W, int Q[MN][MN]) {

  int l = 1, h = R*C, target = H*W/2, ans;
  while(l <= h) {
    int X = (l+h)/2;

    bool chk = 0;
    for(int r=0; r<R; ++r) {
      for(int c=0; c<C; ++c) {
        pfs[r][c] = Q[r][c] <= X;
        if(r > 0) pfs[r][c] += pfs[r-1][c];
        if(c > 0) pfs[r][c] += pfs[r][c-1];
        if(r > 0 && c > 0) pfs[r][c] -= pfs[r-1][c-1];
      }
    }
    for(int r=0; r+H-1<R; ++r) {
      for(int c=0; c+W-1<C; ++c) {
        if(qry(r, c, r+H-1, c+W-1) > target) {
          chk = 1;
        }
      }
    }

    if(chk) {
      h = X-1;
      ans = X;
    } else l = X+1;
  }
  return ans;
}

Compilation message

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3002])':
quality.cpp:43:10: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |   return ans;
      |          ^~~
/usr/bin/ld: /tmp/ccj2nDAX.o: in function `main':
grader.cpp:(.text.startup+0xe9): undefined reference to `rectangle(int, int, int, int, int (*) [3001])'
collect2: error: ld returned 1 exit status