이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX_D = 5000;
int frecvX[MAX_D], frecvY[MAX_D], f[MAX_D];
vector<int> vx[MAX_D];
int main() {
int n, m, d;
cin >> n >> m >> d;
for ( int i = 0; i < n; i++ ) {
int x, y;
cin >> x >> y;
frecvX[x]++;
frecvY[y]++;
}
for ( int i = 0; i < m; i++ ) {
int x, y;
cin >> x >> y;
vx[x].push_back( y );
frecvY[y]++;
}
int minArea = d * d;
for ( int l = 0; l < d; l++ ) {
for ( int i = 0; i < d; i++ )
f[i] = frecvY[i];
int countX = 0;
for ( int r = l; r < d; r++ ) {
countX += frecvX[r];
for ( int y: vx[r] )
f[y]--;
int max0 = 0, crt0 = 0;
for ( int i = 0; i < d; i++ ) {
if ( f[i] == 0 )
crt0++;
else
crt0 = 0;
max0 = max( max0, crt0 );
}
int pref0 = 0;
while ( pref0 < d && f[pref0] == 0 )
pref0++;
int suf0 = 0;
while ( suf0 < n && f[d - 1 - suf0] == 0 )
suf0++;
max0 = max( max0, min( d, suf0 + pref0 ) );
if ( countX >= n )
minArea = min( minArea, (r - l + 1) * (d - max0) );
}
for ( int r = 0; r < l; r++ ) {
countX += frecvX[r];
for ( int y: vx[r] )
f[y]--;
int max0 = 0, crt0 = 0;
for ( int i = 0; i < d; i++ ) {
if ( f[i] == 0 )
crt0++;
else
crt0 = 0;
max0 = max( max0, crt0 );
}
int pref0 = 0;
while ( pref0 < d && f[pref0] == 0 )
pref0++;
int suf0 = 0;
while ( suf0 < n && f[d - 1 - suf0] == 0 )
suf0++;
max0 = max( max0, min( d, suf0 + pref0 ) );
if ( countX >= n )
minArea = min( minArea, (d - l + r + 1) * (d - max0) );
}
}
cout << minArea;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |