Submission #864600

#TimeUsernameProblemLanguageResultExecution timeMemory
864600vnm06New Home (APIO18_new_home)C++14
5 / 100
5066 ms5640 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; int n, k, q; int blz[300005]; int a[300005], b[300005], t[300005], x[300005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k>>q; for(int i=0; i<n; i++) { cin>>x[i]>>t[i]>>a[i]>>b[i]; } for(int i=0; i<q; i++) { int pos, vr; cin>>pos>>vr; for(int j=1; j<=k; j++) blz[j]=1e9; for(int j=0; j<n; j++) { if(a[j]>vr || b[j]<vr) continue; int st=x[j]-pos; if(st<0) st=-st; if(blz[t[j]]>st) blz[t[j]]=st; } int mx=0; for(int j=1; j<=k; j++) mx=max(mx, blz[j]); if(mx==1e9) cout<<-1<<endl; else cout<<mx<<endl; } return 0; } /** 4 2 4 3 1 1 10 9 2 2 4 7 2 5 7 4 1 8 10 5 3 5 6 5 9 1 10 */
#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...