Submission #1144054

#TimeUsernameProblemLanguageResultExecution timeMemory
1144054cleptopodGarden (JOI23_garden)C++20
30 / 100
3095 ms9728 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 l = 0; l < d; l++) { for (int r = l; r < d; r++) { vector<int> x, y; for (int i = 0; i < m; i++) { if (l <= type_b[i].second && type_b[i].second <= r) { y.push_back(type_b[i].second); } else { x.push_back(type_b[i].first); } } for (int i = 0; i < n; i++) { x.push_back(type_a[i].first); y.push_back(type_a[i].second); } sort(x.begin(), x.end()); sort(y.begin(), y.end()); int mx_x_dif = 0, gx = x.back() - x[0]; for (int i = 0; i + 1 < x.size(); i++) { mx_x_dif = max(mx_x_dif, x[i + 1] - x[i]); } bool ok = true; for (int i = 0; i < y.size(); i++) { if (y[i] < l || y[i] > r) { ok = false; } } if (!ok) { continue; } mn = min(mn, (r - l + 1) * min(d - mx_x_dif + 1, gx + 1)); } } for (int l = 0; l < d; l++) { for (int r = l; r < d; r++) { vector<int> x, y; for (int i = 0; i < m; i++) { if (!(l < type_b[i].second && type_b[i].second < r)) { y.push_back(type_b[i].second); } else { x.push_back(type_b[i].first); } } for (int i = 0; i < n; i++) { x.push_back(type_a[i].first); y.push_back(type_a[i].second); } sort(x.begin(), x.end()); sort(y.begin(), y.end()); int mx_x_dif = 0, gx = x.back() - x[0]; for (int i = 0; i + 1 < x.size(); i++) { mx_x_dif = max(mx_x_dif, x[i + 1] - x[i]); } bool ok = true; for (int i = 0; i < y.size(); i++) { if (l < y[i] && y[i] < r) { ok = false; } } if (!ok) { continue; } mn = min(mn, (d - (r - l) + 1) * min(d - mx_x_dif + 1, gx + 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...