제출 #827973

#제출 시각아이디문제언어결과실행 시간메모리
827973LoboGarden (JOI23_garden)C++17
6 / 100
3061 ms8636 KiB
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = -1;

void solve() {
    int n, m, d;
    cin >> n >> m >> d;

    vector<pair<int,int>> t1,t2;
    for(int i = 0; i < n; i++) {
        int x,y; cin >> x >> y;
        t1.pb(mp(x,y));
    }
    for(int i = 0; i < m; i++) {
        int x,y; cin >> x >> y;
        t2.pb(mp(x,y));
    }

    int ans = inf;
    for(int y0 = 0; y0 < 2*d; y0++) {
        for(int y1 = y0; y1 < 2*d; y1++) {
            for(int x0 = 0; x0 < 2*d; x0++) {
                for(int x1 = 0; x1 < 2*d; x1++) {
                    bool ok = true;
                    for(auto X : t1) {
                        int x = X.fr;
                        int y = X.sc;
                        if(!(((x0 <= x && x <= x1) || (x0 <= x+d && x+d <= x1)) && ((y0 <= y && y <= y1) || (y0 <= y+d && y+d <= y1)))) ok = false;
                    }
                    for(auto X : t2) {
                        int x = X.fr;
                        int y = X.sc;
                        if(!(((x0 <= x && x <= x1) || (x0 <= x+d && x+d <= x1)) || ((y0 <= y && y <= y1) || (y0 <= y+d && y+d <= y1)))) ok = false;
                    }
                    if(ok) ans = min(ans, (y1-y0+1)*(x1-x0+1));
                }
            }
        }
    }

    cout << ans << endl;
}
    
int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    int tt = 1;
    // cin >> tt;
    while(tt--) {
        solve();
    }

}
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...