(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #965429

#TimeUsernameProblemLanguageResultExecution timeMemory
965429PringGarden (JOI23_garden)C++17
30 / 100
3053 ms1760 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3","unroll-loops") #pragma GCC target("avx2","popcnt","sse4","abm") using namespace std; #ifdef MIKU string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x) void dout() { cout << dbrs << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) using ll = long long; typedef pair<int, int> pii; const int MXN = 5005; int n, m, d, p[MXN], q[MXN]; multiset<int> MS; vector<int> bck[MXN * 2]; int ori; int CALC_ORI() { vector<int> v; FOR(i, 0, n + m) v.push_back(q[i]); sort(v.begin(), v.end()); int ans = 0; FOR(i, 1, n + m) ans = max(ans, v[i] - v[i - 1]); ans = max(ans, d - v.back() + v.front()); return ans; } int calc(int sr) { int big = ori, cnt = 0, ans = INT_MAX; FOR(i, 0, d) { for (auto &j : bck[sr + i]) { if (j < n) cnt++; else { auto it = MS.find(q[j] + d); auto itr = next(it), itl = prev(it); big = max(big, *itr - *itl); MS.erase(MS.find(q[j])); MS.erase(MS.find(q[j] + d)); MS.erase(MS.find(q[j] + d + d)); } if (cnt == n) ans = min(ans, (i + 1) * (d - big + 1)); } } FOR(i, n, n + m) { MS.insert(q[i]); MS.insert(q[i] + d); MS.insert(q[i] + d + d); } return ans; } void miku() { cin >> n >> m >> d; FOR(i, 0, n + m) { cin >> p[i] >> q[i]; bck[p[i]].push_back(i); bck[p[i] + d].push_back(i); } ori = CALC_ORI(); FOR(i, 0, n + m) { MS.insert(q[i]); MS.insert(q[i] + d); MS.insert(q[i] + d + d); } int ans = INT_MAX; FOR(i, 0, d) ans = min(ans, calc(i)); cout << ans << '\n'; } int32_t main() { cin.tie(0) -> sync_with_stdio(false); cin.exceptions(cin.failbit); miku(); 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...