Submission #982325

#TimeUsernameProblemLanguageResultExecution timeMemory
982325Sir_Ahmed_ImranNew Home (APIO18_new_home)C++17
12 / 100
3387 ms63912 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define append push_back #define add insert #define nl '\n' #define ff first #define ss second #define pii pair<int,int> #define pll pair<ll,ll> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define terminator main #define N 60000 #define K 401 int t[N]; int x[N]; int l[N]; int ans[N]; set<int> s; multiset<int> c[K]; map<int,vector<int>> a; map<int,vector<int>> b; map<int,vector<int>> Q; void solve(){ int n,m,k,p,q,r; cin>>n>>k>>m; for(int i=1;i<=k;i++){ c[i].add(-1e9); c[i].add(1e9); } for(int i=0;i<n;i++){ cin>>x[i]>>t[i]>>p>>q; a[p].append(i); b[q].append(i); s.add(p); s.add(q); } for(int i=0;i<m;i++){ cin>>l[i]>>p; Q[p].append(i); s.add(p); } for(auto& i:s){ for(auto& j:a[i]) c[t[j]].add(x[j]); for(auto& j:Q[i]){ r=-1; for(int z=1;z<=k;z++){ p=*(--c[z].lower_bound(l[j])); q=*c[z].lower_bound(l[j]); p=min(l[j]-p,q-l[j]); r=max(p,r); } if(r>1e8) r=-1; ans[j]=r; } for(auto& j:b[i]) c[t[j]].erase(c[t[j]].find(x[j])); } for(int i=0;i<m;i++) cout<<ans[i]<<nl; } int terminator(){ L0TA; 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...