This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
int op[400];
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);
}
for(int i = 0; i < 200; i++) op[i] = 0;
for(auto [x, y] : b){
if(x < i) x += d;
if(y < j) y += d;
op[x] = max(op[x], y);
}
int mx = w;
for(int k = 200; k >= 0; k--){
ans = min(ans, (max(k, h) - i + 1) * (mx - j + 1));
mx = max(mx, op[k]);
}
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... |