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>
///#include <fstream>
#define endl '\n'
#define mod 998244353
#define INF 100000000000000
#define ll long long
///#define cin fin
///#define cout fout
#define fi first
#define se second
using namespace std;
///ofstream fout("herding.out");
///ifstream fin("herding.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, k, q; cin >> n >> k >> q;
pair<pair<long long, int>,pair<long long, long long>> arr[n];
for(int i = 0; i < n; i++) {
cin >> arr[i].fi.fi >> arr[i].fi.se >> arr[i].se.fi >> arr[i].se.se;
}
while(q--) {
long long ans = 0;
long long dis[k+1];
for(int i = 1; i <= k; i++) dis[i] = INF;
long long pos, y; cin >> pos >> y;
for(int i = 0; i < n; i++) {
if(arr[i].se.fi <= y && arr[i].se.se >= y) dis[arr[i].fi.se] = min(dis[arr[i].fi.se],abs(arr[i].fi.fi-pos));
}
for(int i = 1; i <= k; i++) {
if(dis[i] == INF) {
ans = -1;
break;
}
else {
ans = max(ans,dis[i]);
}
}
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... |