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