Submission #744354

#TimeUsernameProblemLanguageResultExecution timeMemory
744354AbitoNew Home (APIO18_new_home)C++17
5 / 100
5023 ms21656 KiB
#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 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...