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>
#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 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... |