Submission #1009138

#TimeUsernameProblemLanguageResultExecution timeMemory
1009138Muaath_5Quality Of Living (IOI10_quality)C++17
Compilation error
0 ms0 KiB
#include "quality.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 3003;
ll pref[N][N];
ll query(int x1, int y1, int x2, int y2) {
  return pref[x2][y2] - pref[x2][y1-1] - pref[x1-1][y2] + pref[x1-1][y1-1];
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
  	int l = 1, r = R*C;
  	while (l < r) {
      const int mid = (l+r+1)/2;
      for (int i = 1; i <= R; i++) {
        for (int j = 1; j <= C; j++) {
          pref[i][j] = Q[i-1][j-1] >= mid;
          pref[i][j] += pref[i][j-1];
        }
      }
      for (int i = 1; i <= R; i++) {
        for (int j = 1; j <= C; j++) {
          pref[i][j] += pref[i-1][j];
        }
      }
      int sum = 0;
      bool ok = false;
      for (int i = 1; i <= R-H+1; i++) {
        for (int j = 1; j <= C-W+1; j++) {
          if (query(i, j, i+H-1, j+W-1) >= H*W/2 + (H*W%2)) {
            ok = true;
          }
        }
      }
      if (ok)
        	l = mid;
      else
        	r = mid-1;
    }
  	return l;
}

Compilation message (stderr)

quality.cpp:5:1: error: 'll' does not name a type
    5 | ll pref[N][N];
      | ^~
quality.cpp:6:1: error: 'll' does not name a type
    6 | ll query(int x1, int y1, int x2, int y2) {
      | ^~
quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:15:11: error: 'pref' was not declared in this scope
   15 |           pref[i][j] = Q[i-1][j-1] >= mid;
      |           ^~~~
quality.cpp:21:11: error: 'pref' was not declared in this scope
   21 |           pref[i][j] += pref[i-1][j];
      |           ^~~~
quality.cpp:28:15: error: 'query' was not declared in this scope
   28 |           if (query(i, j, i+H-1, j+W-1) >= H*W/2 + (H*W%2)) {
      |               ^~~~~
quality.cpp:24:11: warning: unused variable 'sum' [-Wunused-variable]
   24 |       int sum = 0;
      |           ^~~