Submission #965267

#TimeUsernameProblemLanguageResultExecution timeMemory
965267phoenix0423Garden (JOI23_garden)C++17
14 / 100
3064 ms8280 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define fastio ios::sync_with_stdio(false), cin.tie(0) #pragma GCC optimize("Ofast") #define pb push_back #define eb emplace_back #define f first #define s second #define int long long #define lowbit(x) x&-x const int maxn = 4000 + 5; const int INF = 1e18; signed main(void){ fastio; int n, m, d; cin>>n>>m>>d; vector<pll> a(n), b(m); for(int i = 0; i < n; i++) cin>>a[i].f>>a[i].s; for(int i = 0; i < m; i++) cin>>b[i].f>>b[i].s; int ans = INF; for(int i = 0; i < d; i++){ for(int j = 0; j < d; j++){ int h = 0, w = 0; for(auto [x, y] : a){ if(x < i) x += d; if(y < j) y += d; h = max(h, x); w = max(w, y); } // cout<<"beg : "<<h - i<<" "<<w - j<<"\n"; vector<pll> op; for(auto [x, y] : b){ if(x < i) x += d; if(y < j) y += d; op.pb({x, y}); } sort(op.begin(), op.end(), greater<pll>()); int mx = w; for(auto [x, y] : op){ // cout<<"ck : "<<i<<" "<<j<<" "<<max(x, h)<<" "<<mx<<"\n"; ans = min(ans, (max(x, h) - i + 1) * (mx - j + 1)); mx = max(mx, y); } // cout<<"ck : "<<i<<" "<<j<<" "<<h<<" "<<mx<<"\n"; ans = min(ans, (h - i + 1) * (mx - j + 1)); } } cout<<ans<<"\n"; }
#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...