Submission #287205

#TimeUsernameProblemLanguageResultExecution timeMemory
287205ScarletSNew Home (APIO18_new_home)C++17
5 / 100
5054 ms15888 KiB
#include <bits/stdc++.h> #define ll long long #define sz(x) (int)(x).size(); using namespace std; const int MAXN=3e5+7; int n,k,x,y,cur,ans,INF=1e9,a[MAXN][4]; vector<int> present[MAXN]; ll solve() { ans=0; cin>>x>>y; for (int i=1;i<=k;++i) present[i].clear(); for (int i=0;i<n;++i) if (a[i][2]<=y&&y<=a[i][3]) present[a[i][1]].push_back(a[i][0]); for (int i=1;i<=k;++i) { if (present[i].empty()) return -1; cur=INF; for (int j : present[i]) cur=min(cur,abs(j-x)); //cout<<cur<<"\n"; ans=max(cur,ans); } return ans; } int main() { int q; cin>>n>>k>>q; for (int i=0;i<n;++i) for (int j=0;j<4;++j) cin>>a[i][j]; while (q--) cout<<solve()<<"\n"; }
#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...