제출 #998734

#제출 시각아이디문제언어결과실행 시간메모리
998734ZeroCool삶의 질 (IOI10_quality)C++14
0 / 100
1 ms6492 KiB
#include "quality.h" #include <bits/stdc++.h> #define ar array #define ll long long int n, m, h, w; const int N = 3005; int A[N][N]; int B[N][N]; int query(int x1, int y1, int x2, int y2){ int res = B[x2][y2]; if(x1)res -= B[x1-1][y2]; if(y1)res -= B[x2][y1-1]; if(x1 && y1)res += B[x1-1][y1-1]; return res; } bool check(int k){ for(int i = 0;i<n;i++){ for(int j = 0;j<m;j++){ B[i][j] = (A[i][j] <= k); } } for(int i = 1;i<n;i++){ for(int j = 1;j<m;j++){ B[i][j] += B[i-1][j]; B[i][j] += B[i][j-1]; B[i][j] -= B[i-1][j-1]; } } for(int i = 0;i + h - 1 < n;i++){ for(int j = 0;j + w - 1 < m;j++){ if(query(i, j, i + h - 1, j + w - 1) >= (w * h) / 2 + 1)return 1; } } return 0; } int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { n = R; m = C; h = H; w = W; for(int i = 0;i<n;i++){ for(int j = 0;j<m;j++){ A[i][j] = Q[i][j]; } } int lo = 1; int hi = n * m; int ans = -1; while(lo <= hi){ int mid = (lo + hi) / 2; if(check(mid)){ ans = mid; hi = mid - 1; }else lo = mid + 1; } 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...