Submission #943466

#TimeUsernameProblemLanguageResultExecution timeMemory
943466IBoryQuality Of Living (IOI10_quality)C++17
Compilation error
0 ms0 KiB
const int MAX = 3001; int Y[MAX * MAX], X[MAX * MAX]; int rectangle(int R, int C, int H, int W, int S[MAX][MAX]) { for (int i = 1; i <= R; ++i) for (int j = 1; j <= C; ++j) { int n = S[i - 1][j - 1]; Y[n] = i, X[n] = j; } int L = 0, R = R * C + 1; while (L + 1 < R) { int mid = (L + R) >> 1; for (int i = 1; i <= mid; ++i) S[Y[i]][X[i]] = 1; for (int i = mid + 1; i <= R * C; ++i) S[Y[i]][X[i]] = 0; for (int i = 1; i <= R; ++i) for (int j = 1; j <= C; ++j) S[i][j] += S[i][j - 1]; for (int j = 1; j <= C; ++j) for (int i = 1; i <= R; ++i) S[i][j] += S[i - 1][j]; int high = 0; for (int i = H; i <= R; ++i) for (int j = W; j <= C; ++j) { int s = S[i][j] - S[i - H][j] - S[i][j - W] + S[i - H][j - W]; high = max(high, s); } ((H * W + 1) / 2 <= high ? R : L) = mid; } return R; }

Compilation message (stderr)

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:10:13: error: declaration of 'int R' shadows a parameter
   10 |  int L = 0, R = R * C + 1;
      |             ^
quality.cpp:4:19: note: 'int R' previously declared here
    4 | int rectangle(int R, int C, int H, int W, int S[MAX][MAX]) {
      |               ~~~~^
quality.cpp:21:11: error: 'max' was not declared in this scope
   21 |    high = max(high, s);
      |           ^~~