제출 #303052

#제출 시각아이디문제언어결과실행 시간메모리
303052iliccmarko삶의 질 (IOI10_quality)C++14
80 / 100
5061 ms145068 KiB
#include <bits/stdc++.h> #include<quality.h> using namespace std; #define ll long long #define endl "\n" using namespace std; int rectangle(int r, int c, int h, int w, int q[3001][3001]) { int l = 1; int R = r*c; int ans; while(l<=R) { int mid = (l+R)/2; int mat[r][c]; for(int i = 0;i<r;i++) { for(int j = 0;j<c;j++) { if(q[i][j]<mid) mat[i][j] = -1; else if(q[i][j]==mid) mat[i][j] = 0; else mat[i][j] = 1; } } int prefix[r][c]; for(int i = 0;i<r;i++) { for(int j = 0;j<c;j++) { if(j==0) { prefix[i][j] = mat[i][j]; } else { prefix[i][j] = prefix[i][j-1] + mat[i][j]; } } } int s, e; s = e = 0; int sum = 0; for(int i = w-1;i<c;i++) { sum = 0; for(int j = 0;j<h;j++) { if(i==w-1) { sum+=prefix[j][w-1]; } else { sum+=prefix[j][i] - prefix[j][i-w]; } } if(sum<0) { s++; break; } else if(sum==0) { e++; } for(int j = h;j<r;j++) { if(i==w-1) { sum-=prefix[j-h][w-1]; sum+=prefix[j][w-1]; } else { sum-=prefix[j-h][i] - prefix[j-h][i-w]; sum+=prefix[j][i] - prefix[j][i-w]; } if(sum<0) { s++; break; } else if(sum==0) { e++; } } if(s!=0) break; } if(s) { R = mid - 1; } else if(e) { ans = mid; break; } else { l = mid + 1; } } return ans; }

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

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