이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define int long long
#define lowbit(x) x&-x
const int maxn = 4000 + 5;
const int INF = 1e18;
signed main(void){
fastio;
int n, m, d;
cin>>n>>m>>d;
vector<pll> a(n), b(m);
for(int i = 0; i < n; i++) cin>>a[i].f>>a[i].s;
for(int i = 0; i < m; i++) cin>>b[i].f>>b[i].s;
int ans = INF;
for(int i = 0; i < d; i++){
for(int j = 0; j < d; j++){
int h = 0, w = 0;
for(auto [x, y] : a){
if(x < i) x += d;
if(y < j) y += d;
h = max(h, x);
w = max(w, y);
}
// cout<<"beg : "<<h - i<<" "<<w - j<<"\n";
vector<pll> op;
for(auto [x, y] : b){
if(x < i) x += d;
if(y < j) y += d;
op.pb({x, y});
}
sort(op.begin(), op.end(), greater<pll>());
int mx = w;
for(auto [x, y] : op){
// cout<<"ck : "<<i<<" "<<j<<" "<<max(x, h)<<" "<<mx<<"\n";
ans = min(ans, (max(x, h) - i + 1) * (mx - j + 1));
mx = max(mx, y);
}
// cout<<"ck : "<<i<<" "<<j<<" "<<h<<" "<<mx<<"\n";
ans = min(ans, (h - i + 1) * (mx - j + 1));
}
}
cout<<ans<<"\n";
}
# | 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... |