Submission #734883

#TimeUsernameProblemLanguageResultExecution timeMemory
734883phoebeQuality Of Living (IOI10_quality)C++17
0 / 100
15 ms35668 KiB
#include <bits/stdc++.h> #include "quality.h" using namespace std; int rectangle(int R, int C, int H, int W, int Q[3001][3001]){ int prefix[3001][3001]; int l = 0, r = 3001 * 3001, ans; while (l <= r){ int mid = (l + r) / 2; for (int i = 0; i <= R; i++) prefix[i][0] = 0; for (int j = 0; j <= C; j++) prefix[0][j] = 0; for (int i = 1; i <= R; i++){ for (int j = 1; j <= C; j++){ if (Q[i - 1][j - 1] >= mid) prefix[i][j] = 1; else prefix[i][j] = -1; prefix[i][j] += prefix[i][j - 1]; } } for (int i = 1; i <= R; i++){ for (int j = 1; j <= C; j++) prefix[i][j] += prefix[i - 1][j]; } bool pos = false; for (int i = H; i <= R; i++){ for (int j = W; j <= C; j++){ int val = prefix[i][j] - prefix[i - H][j] - prefix[i][j - W] + prefix[i - H][j - W]; if (val + val > H * W) pos = true; } } if (pos) ans = mid, r = mid - 1; else l = mid + 1; } return ans; }

Compilation message (stderr)

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:34:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |     return ans;
      |            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...