제출 #950875

#제출 시각아이디문제언어결과실행 시간메모리
950875Yell0삶의 질 (IOI10_quality)C++17
컴파일 에러
0 ms0 KiB
#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; }

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

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