(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #659320

#TimeUsernameProblemLanguageResultExecution timeMemory
659320stevancvQuality Of Living (IOI10_quality)C++14
100 / 100
2271 ms175956 KiB
#include <bits/stdc++.h> #include "quality.h" #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 3e3 + 2; const int inf = 2e9; int rectangle(int n, int m, int h, int w, int q[3001][3001]) { vector<vector<int>> a(n + 1, vector<int>(m + 1)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { a[i][j] = q[i - 1][j - 1]; } } auto Can = [&] (int x) { vector<vector<int>> p(n + 1, vector<int>(m + 1, 0)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (a[i][j] > x) p[i][j] = -1; else if (a[i][j] < x) p[i][j] = 1; p[i][j] += p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1]; } } for (int i = h; i <= n; i++) { for (int j = w; j <= m; j++) { if (p[i][j] - p[i - h][j] - p[i][j - w] + p[i - h][j - w] >= 0) return true; } } return false; }; int l = 1, r = n * m, ans = n * m; while (l <= r) { int mid = l + r >> 1; if (Can(mid)) { r = mid - 1; ans = mid; } else l = mid + 1; } return ans; }

Compilation message (stderr)

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:37:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   37 |         int mid = l + r >> 1;
      |                   ~~^~~
#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...