Submission #950876

#TimeUsernameProblemLanguageResultExecution timeMemory
950876Yell0Quality Of Living (IOI10_quality)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MN=3001; 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; } int main() { ios::sync_with_stdio(0);cin.tie(0); int R,C,H,W; cin>>R>>C>>H>>W; for(int r=0; r<R; ++r) { for(int c=0; c<C; ++c) cin>>q[r][c]; } cout<<rectangle(R,C,H,W,q)<<'\n'; return 0; }

Compilation message (stderr)

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:43:10: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |   return ans;
      |          ^~~
/usr/bin/ld: /tmp/cc3SOSGm.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccaBK2io.o:quality.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status