Submission #952262

#TimeUsernameProblemLanguageResultExecution timeMemory
952262Doncho_BonbonchoQuality Of Living (IOI10_quality)C++14
40 / 100
5028 ms5724 KiB
#include <bits/stdc++.h> #include "quality.h" #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } #ifndef LOCAL #define cerr if(false) cerr #define endl "\n" #endif #define out(x) #x << "=" << x << " " int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { if( R < C ){ for( int i=0 ; i < H/2 ; i++ ){ for( int j=0 ; j < W/2 ; j++ ){ std::swap( Q[i][j], Q[j][i] ); } } std::swap( R, C ); std::swap( H, W ); } int nas = R * C +1; std::set< int > S; for( int i=0 ; i + H <= R ; i ++ ){ S.clear(); for( int I = i; I < i + H ; I++ ){ int j = 0; for( int J = j ; J < j + W ; J++ ){ S.insert( Q[I][J] ); } } for( int j=0 ; j + W <= C ; j++ ){ if( j ){ for( int I = i ; I < i + H ; I++ ){ S.erase( Q[I][j-1] ); S.insert( Q[I][j+W-1] ); } } auto it = S.begin(); std::advance( it, S.size()/2 ); cerr << out( *it ) << endl; chkmin( nas, *it ); } } return nas; }
#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...