Submission #208957

#TimeUsernameProblemLanguageResultExecution timeMemory
2089572Nor22Quality Of Living (IOI10_quality)C++14
0 / 100
5 ms760 KiB
#include <unordered_set> #include <unordered_map> #include <algorithm> #include <iostream> #include <fstream> #include <string> #include <cstring> #include <cstdint> #include <cstdlib> #include <cstdio> #include <cctype> #include <cmath> #include <vector> #include <bitset> #include <queue> #include <deque> #include <stack> #include <cmath> #include <tuple> #include <list> #include <set> #include <map> #define add push_back #define m_p make_pair #define fr first #define sc second #define endl '\n' using namespace std; typedef long long ll; typedef unsigned long long llu; typedef long double ld; typedef pair<ll, ll> pii; const ll N = 1000005, mod = 998244353, M = 3005; ll n, m, k, i, j, ans, kaskad[N], matrix[M][M], quality[M][M], pref[M][M]; ll h, w; bool check(ll value) { for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { int x = 0; if (matrix[i][j] > value) x = 1; else if(matrix[i][j] < value) x = -1; pref[i + 1][j + 1] = pref[i][j + 1] + pref[i + 1][j] - pref[i][j] + x; } } for (int i = h; i <= n; ++i) { for (int j = w; j <= m; ++j) { if (pref[i][j] - pref[i - h][j] - pref[i][j - w] + pref[i - h][j - w] <= 0) return true; } } return false; } void BinarySearch(ll left, ll right) { ans = right; if (right - left <= 1) return; ll mid = (left + right) / 2; if (!check(mid)) { BinarySearch(mid, right); } else { BinarySearch(left, mid); } } int rectangle(int r, int c, int hh, int ww, int a[3001][3001]) { n = r; m = c; h = hh; w = ww; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { matrix[i][j] = a[i][j]; } } BinarySearch(0, h*w); 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...