This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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<int> val(k,1e9);
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--;
}
for(int i=0;i<q;i++){
int l,y;
cin >> l >> y;
fill(val.begin(),val.end(),1e9);
for(int j=0;j<n;j++){
if(vp[j].sc.fs<=y && vp[j].sc.sc>=y){
val[vp[j].fs.sc]=min(val[vp[j].fs.sc],abs(l-vp[j].fs.fs));
}
}
int ans=0;
for(int j=0;j<k;j++){
ans=max(ans,val[j]);
}
if(ans>5e8){
cout << -1 << "\n";
continue;
}
cout << ans << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |