Submission #1302319

#TimeUsernameProblemLanguageResultExecution timeMemory
1302319tripadvaQuality Of Living (IOI10_quality)C++20
100 / 100
975 ms106272 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; } void dbg_out() { cerr << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); } template <class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; #ifdef LOCAL #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif #define ar array typedef long long ll; typedef long double ld; typedef complex<ld> cd; #define sza(x) ((int)x.size()) #define all(a) (a).begin(), (a).end() #define sort(a) sort(all(a)) #define mp make_pair #define pb push_back #define f first #define s second typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; typedef vector<cd> vcd; template<class T> using pq = priority_queue<T>; template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>; const int MAX_N = 1e5 + 5; const ll MOD = 1e9 + 7; const ll INF = 1e9; const ld EPS = 1e-9; const char nl = '\n'; const long long int ll_MAX=9223372036854775807; const string deb = "------------"; //[x,y],[a,b] int stepenDvojke(int n) { int s = 1; while (s < n) s <<= 1; return s; } int a[3001][3001]; int A[3001][3001]; int h,w,N,M; bool check(int k){ memset(A, 0, sizeof(A)); for(int i=1;i<=N;i++) for(int j=1;j<=M;j++) A[i][j] = (a[i-1][j-1] <= k ? 1 : -1); for(int i =1;i<=N;i++){ for(int j = 1;j<=M;j++){ A[i][j] = A[i][j] + A[i-1][j] + A[i][j-1] - A[i-1][j-1]; } } for(int i =h;i<=N;i++){ for(int j = w;j<=M;j++){ if(A[i][j]-A[i-h][j]-A[i][j-w]+A[i-h][j-w]>=0)return true; } } return false; } int rectangle(int R, int C, int H, int W, int P[3001][3001]){ N=R; M=C; h=H; w=W; for(int i =0;i<N;i++){ for(int j =0;j<M;j++){ a[i][j]=P[i][j]; } } int l = 1,r= N*M,rez = N*M; while(l<=r){ int mid = (l+r)/2; if(check(mid))r=mid-1,rez=mid; else l=mid+1; } return rez; }
#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...