#include<bits/stdc++.h>
using namespace std;
#ifndef BADGNU
#pragma GCC target("sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define int ll
#define ld long double
#define y1 cheza
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=5e5+100;
const int M=5001;
const int B=447;
const int mod=998244353;
const ll INF=1e18;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const double eps=1e-6;
int n,m,d;
pair<int,int>a[N],b[N];
void test(){
cin>>n>>m>>d;
for(int i=1;i<=n;i++){
cin>>a[i].first>>a[i].second;
}
for(int i=1;i<=m;i++){
cin>>b[i].first>>b[i].second;
}
int ans=INF;
for(int i=0;i<d;i++){
for(int j=0;j<d;j++){
int x=i;
int y=j;
for(int w=1;w<=n;w++){
if(a[w].first>=i&&a[w].second>=j){
x=max(x,a[w].first);
y=max(y,a[w].second);
continue;
}
if(a[w].first>=i&&a[w].second+d>=j){
x=max(x,a[w].first);
y=max(y,a[w].second+d);
continue;
}
if(a[w].first+d>=i&&a[w].second>=j){
x=max(x,a[w].first+d);
y=max(y,a[w].second);
continue;
}
x=max(x,a[w].first+d);
y=max(y,a[w].second+d);
}
// cout<<x<<' '<<y<<'\n';
if(x<y){
for(int w=1;w<=m;w++){
if(b[w].second>=j){
y=max(y,b[w].second);
continue;
}
if(b[w].second+d>=j){
y=max(y,b[w].second+d);
continue;
}
}
}
else{
for(int w=1;w<=m;w++){
if(b[w].second>=j){
y=max(y,b[w].second);
continue;
}
if(b[w].second+d>=j){
y=max(y,b[w].second+d);
continue;
}
}
}
ans=min(ans,(x-i+1)*(y-j+1));
}
}
// 0 0 5
// 1 2
// 1 5
// 2 5
cout<<ans<<'\n';
}
/*
*/
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// cout.tie(nullptr);
int t2=1;
// cin>>t2;
for(int i=1;i<=t2;i++){
test();
}
}
# | 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... |