(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 #481763

#TimeUsernameProblemLanguageResultExecution timeMemory
481763SlavicGQuality Of Living (IOI10_quality)C++17
100 / 100
2705 ms106112 KiB
#include"quality.h" #include "bits/stdc++.h" using namespace std; #define ll long long #define forn(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(),v.rend() #define pb push_back #define sz(a) (int)a.size() const int N = 3001; int p1[N][N]; int p2[N][N]; int smaller(int x1, int y1, int x2, int y2){ return p1[x2][y2] - p1[x1 - 1][y2] - p1[x2][y1 - 1] + p1[x1 - 1][y1 - 1]; } int fuck(int x1, int y1, int x2, int y2){ return p2[x2][y2] - p2[x1 - 1][y2] - p2[x2][y1 - 1] + p2[x1 - 1][y1 - 1]; } int rectangle(int n, int m, int a, int b, int c[3001][3001]){ int ans = INT_MAX; int l = 1,r = n * m; while(l <= r) { int mid = l + r >> 1; forn(i, N)forn(j, N)p1[i][j] = p2[i][j] = 0; //didnt qualify to iom because of this line :( for(int i = 0;i < n;++i){ for(int j = 0;j < m;++j){ if(c[i][j] < mid)p1[i + 1][j + 1] = 1; if(c[i][j] > mid)p2[i + 1][j + 1] = 1; } } for(int i = 1;i <= n;++i){ for(int j = 1;j <= m;++j){ p1[i][j] += p1[i - 1][j] + p1[i][j - 1] - p1[i - 1][j - 1]; p2[i][j] += p2[i - 1][j] + p2[i][j - 1] - p2[i - 1][j - 1]; } } bool ok = false; for(int i = 0;i + a - 1 < n;++i){ for(int j = 0;j + b - 1 < m;++j){ int sm = smaller(i + 1, j + 1, i + a, j + b); int gr = fuck(i + 1, j + 1, i + a, j + b); if(sm == gr){ ans = min(ans, mid); ok = true; }else if(sm > gr)ok = true; } } if(ok){ r = mid - 1; }else l = mid + 1; } return ans; }

Compilation message (stderr)

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:32:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |         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...