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 pb push_back
#define F first
#define S second
#define endl '\n'
#define ep insert
#define pow pwr
#define sqrt sqrtt
using namespace std;
const int N=3e5+5;
int n,k,q;
vector<pair<int,pair<int,int>>> adj[N];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>k>>q;
for (int i=1;i<=n;i++){
int x,y,z,w;
cin>>x>>y>>z>>w;
adj[y].pb({x,{z,w}});
}
while (q--){
int x,y;
cin>>x>>y;
int ans=INT_MIN;
for (int i=1;i<=k;i++){
bool ok=false;
int ansx=INT_MAX;
for (auto u:adj[i]){
if (y>=u.S.F && y<=u.S.S){
ok=true;
ansx=min(ansx,abs(x-u.F));
}
}
if (ok){
ans=max(ans,ansx);
continue;
}
ans=-1;
break;
}cout<<ans<<endl;
}
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... |