Submission #811040

#TimeUsernameProblemLanguageResultExecution timeMemory
811040taherGarden (JOI23_garden)C++17
0 / 100
3081 ms90328 KiB
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, d; cin >> n >> m >> d; vector<array<int, 2>> a(n); for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; } vector<array<int, 2>> b(m); for (int i = 0; i < m; i++) { cin >> b[i][0] >> b[i][1]; } vector<array<int, 2>> xs; for (int i = 0; i < n; i++) { xs.push_back({a[i][0], i}); xs.push_back({a[i][0] + d, i}); } for (int i = 0; i < m; i++) { xs.push_back({b[i][0], i + n}); xs.push_back({b[i][0] + d, i + n}); } sort(xs.begin(), xs.end()); int ans = 123456789; for (int i = 0; i < (int) xs.size(); i++) { set<int> fType; set<int> sType; auto Compute = [&](int hori) { vector<array<int, 2>> ys; int cnt = 0; for (int j = 0; j < n; j++) { ys.push_back({a[j][1], j}); ys.push_back({a[j][1] + d, j}); ++cnt; } for (int j = 0; j < m; j++) { if (!sType.count(j + n)) { ++cnt; ys.push_back({b[j][1], j + n}); ys.push_back({b[j][1] + d, j + n}); } } sort(ys.begin(), ys.end()); int vert = 12345; set<int> st; map<int, int> st_cnt; int high = 0; for (int id = 0; id < (int) ys.size(); id++) { while (high < (int) ys.size()) { st.insert(ys[high][1]); st_cnt[ys[high][1]]++; if ((int) st.size() == cnt) { vert = min(vert, ys[high][0] - ys[id][0]); high++; break; } ++high; } st_cnt[ys[id][1]]--; if (st_cnt[ys[id][1]] == 0) { st.erase(ys[id][1]); } } int area = (hori + 1) * (vert + 1); return area; }; for (int j = i; j < (int) xs.size(); j++) { if (xs[j][1] < n) { fType.insert(xs[j][1]); } else { sType.insert(xs[j][1]); } if ((int) fType.size() == n) { ans = min(ans, Compute(xs[j][0] - xs[i][0])); } } } cout << ans << '\n'; 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...