제출 #1144042

#제출 시각아이디문제언어결과실행 시간메모리
1144042cleptopodGarden (JOI23_garden)C++20
0 / 100
3095 ms9736 KiB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "deb.h"
#else
#define debug(...) 
#endif

// In particular, the answer for a fixed 

void solve() {
  int n, m, d;
  cin >> n >> m >> d;
  vector<pair<int, int>> type_a(n), type_b(m);
  for (int i = 0; i < n; i++) {
    cin >> type_a[i].first >> type_a[i].second;
  }
  for (int i = 0; i < m; i++) {
    cin >> type_b[i].first >> type_b[i].second;
  }
  int mn = 1e9;
  for (int i = 0; i < (1 << m); i++) {
    vector<int> x_coords, y_coords;
    for (int j = 0; j < n; j++) {
      x_coords.push_back(type_a[j].first);
      y_coords.push_back(type_a[j].second);
    }
    for (int j = 0; j < m; j++) {
      if (i & (1 << j)) {
        x_coords.push_back(type_b[j].first);
      } else {
        y_coords.push_back(type_b[j].second);
      }
    }
    sort(x_coords.begin(), x_coords.end());
    sort(y_coords.begin(), y_coords.end());
    int mx_x_dif = 0, mx_y_dif = 0;
    for (int j = 0; j + 1 < x_coords.size(); j++) {
      mx_x_dif = max(mx_x_dif, x_coords[j + 1] - x_coords[j]);
    }
    for (int j = 0; j + 1 < y_coords.size(); j++) {
      mx_y_dif = max(mx_y_dif, y_coords[j + 1] - y_coords[j]);
    }
    int gx = x_coords.back() - x_coords[0], gy = y_coords.back() - y_coords[0];
    mn = min(mn, min(gx + 1, d - mx_x_dif + 1) * min(gy + 1, d - mx_y_dif + 1));
  }
  cout << mn << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
#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...