제출 #1034536

#제출 시각아이디문제언어결과실행 시간메모리
1034536belgianbot삶의 질 (IOI10_quality)C++14
0 / 100
0 ms344 KiB
#include "quality.h" #include <bits/stdc++.h> using namespace std; int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { int l = H * W / 2 + 1, r = R * C - 1 - (H * W / 2); int ans; while (l <= r) { int mid = l + (r - l) / 2; bool possible = false; vector<vector<int>> nbSmaller (R, vector<int>(C - W + 1)); vector<vector<int>> nbBigger (R, vector<int>(C - W + 1)); for (int i = 0; i < R; i++) { int cnt = 0, cnt2 = 0; for (int j = 0; j < W; j++) {cnt += (Q[i][j] < mid); cnt2 += (Q[i][j] > mid);} nbSmaller[i][0] = cnt; nbBigger[i][0] = cnt2; for (int j = 0; j < C - W; j++) { cnt -= (Q[i][j] < mid); cnt += (Q[i][j + W] < mid); cnt2 -= (Q[i][j] > mid); cnt2 += (Q[i][j + W] > mid); nbSmaller[i][j + 1] = cnt; nbBigger[i][j + 1] = cnt2; } } /*cout << mid << '\n'; for (auto x : nbSmaller) { for (auto y : x) cout << y << ' '; cout << '\n'; } cout << "\n\n";*/ for (int i = 0; i < C - W + 1; i++) { int cnt = 0, cnt2 = 0; for (int j = 0; j < H; j++) {cnt += nbSmaller[j][i]; cnt2 += nbBigger[j][i];} if (cnt == (W * H) / 2 && cnt + cnt2 < W * H) { possible = true; break; } for (int j = 0; j < R - H; j++) { cnt -= nbSmaller[j][i]; cnt += nbSmaller[j + H][i]; cnt2 -= nbBigger[j][i]; cnt2 += nbBigger[j + H][i]; if (cnt == (W * H) / 2 && cnt2 + cnt < W * H) { possible = true; break; } } if (possible) break; } if (possible) { ans = mid; r = mid - 1; } else { l = mid + 1; } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:61:9: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   61 |  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...