제출 #358427

#제출 시각아이디문제언어결과실행 시간메모리
358427idk321삶의 질 (IOI10_quality)C++98
0 / 100
103 ms71020 KiB
#include "quality.h" #include <bits/stdc++.h> using namespace std; int r, c, h, w, q[3001][3001]; int add[3001][3001]; bool good() { for (int i = 0; i + h - 1 < r; i++) { for (int j = 0; j + w - 1 < c; j++) { int sum = add[i + h - 1][j + w - 1]; if (i != 0) sum -= add[i][j + w - 1]; if (j != 0) sum -= add[i + h - 1][j]; if (i != 0 && j != 0) sum += add[i - 1][j - 1]; if (sum >= (h * w - 1) / 2) return true; } } return false; } void make(int num) { for (int i = 0; i < 3001; i++) { for (int j = 0; j < 3001; j++) add[i][j] = 0; } for (int i = 0; i < r; i++) { for (int j = 0; j < w; j++) { if (q[i][j] <= num) add[i][j] = 1; if (i != 0) add[i][j] += add[i - 1][j]; if (j != 0) add[i][j] += add[i][j - 1]; //cout << num << " " << add[i][j] << " " << q[i][j] << endl; } } } int bs() { int a = 0; int b = r * c; int res = -1; while (a <= b) { int mid = (a + b) / 2; make(mid); bool ok = good(); if (ok) { res = mid + 1; b = mid - 1; } else { a = mid + 1; } } return res; } int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { r = R; c = C; h = H; w = W; for (int i = 0; i < 3001; i++) { for (int j = 0; j < 3001; j++) q[i][j] = Q[i][j]; } return bs(); }
#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...