제출 #894869

#제출 시각아이디문제언어결과실행 시간메모리
894869vjudge1삶의 질 (IOI10_quality)C++17
100 / 100
2533 ms175820 KiB
#include<bits/stdc++.h> using namespace std; vector<vector<int>>grid; bool check(vector<vector<int>>&pref, int R, int C, int H, int W){ for(int i = 1;i <= R;++i){ for(int j = 1;j <= C;++j){ if(i + H - 1 <= R && j + W - 1 <= C){ int num = pref[i + H - 1][j + W - 1] - pref[i - 1][j + W - 1] - pref[i + H - 1][j - 1] + pref[i - 1][j - 1]; if(num >= H * W / 2 + 1)return true; } } } return false; } int rectangle(int R, int C, int H, int W, int Q[3001][3001]){ grid.assign(R + 1, vector<int>(C + 1)); for(int i = 1;i <= R;++i){ for(int j = 1;j <= C;++j){ grid[i][j] = Q[i - 1][j - 1]; } } int l = 1, r = R * C, ans = r; while(l <= r){ int mid = (l + r) >> 1; vector<vector<int>>pref(R + 1, vector<int>(C + 1)); for(int i = 1;i <= R;++i){ for(int j = 1;j <= C;++j){ if(grid[i][j] <= mid){ pref[i][j]++; } pref[i][j] += pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1]; } } if(check(pref, R, C, H, W)){ ans = mid; r = mid - 1; } else{ l = mid + 1; } } return ans; } // int main(){ // ios_base::sync_with_stdio(0); // cin.tie(0); // int n, m, H, W; // cin >> n >> m >> H >> W; // vector<vector<int>>v(n, vector<int>(m)); // for(int i = 0;i < n;++i){ // for(int j = 0;j < m;++j){ // cin >> v[i][j]; // } // } // cout << rectangle(n, m, H, W, v); // }
#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...