Submission #743525

#TimeUsernameProblemLanguageResultExecution timeMemory
743525alvingogoNew Home (APIO18_new_home)C++14
0 / 100
5096 ms57084 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define AquA cin.tie(0);ios_base::sync_with_stdio(0); #define fs first #define sc second #define p_q priority_queue #define int long long using namespace std; typedef pair<int,int> pii; signed main(){ AquA; int n,k,q; cin >> n >> k >> q; vector<pair<pii,pii> > vp(n); vector<pair<int,pii> > g; for(int i=0;i<n;i++){ cin >> vp[i].fs.fs >> vp[i].fs.sc >> vp[i].sc.fs >> vp[i].sc.sc; vp[i].fs.sc--; g.push_back({vp[i].sc.fs,vp[i].fs}); g.push_back({vp[i].sc.sc+1,{vp[i].fs.fs,-vp[i].fs.sc}}); } vector<multiset<int> > s(k); for(int i=0;i<k;i++){ s[i].insert(-2e9); s[i].insert(2e9); } for(int i=0;i<q;i++){ int l,y; cin >> l >> y; g.push_back({l,{-1,y}}); } sort(g.begin(),g.end()); for(auto h:g){ if(h.sc.fs<0){ int ans=0; for(int i=0;i<k;i++){ auto y=s[i].lower_bound(h.sc.sc); auto z=prev(y); ans=max(ans,min((*y)-h.sc.sc,h.sc.sc-(*z))); } cout << ans << "\n"; } else if(h.sc.sc<0){ s[-h.sc.sc].erase(s[-h.sc.sc].find(h.sc.fs)); } else{ s[h.sc.sc].insert(h.sc.fs); } } 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...