This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//In the name of God
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MXN = 400 + 10;
ll n, k, q;
ll X[MXN], T[MXN], A[MXN], B[MXN], mn[MXN];
int main(){
ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
cin >> n >> k >> q;
for(int i = 1; i <= n; i ++) cin >> X[i] >> T[i] >> A[i] >> B[i];
for(int i = 1; i <= q; i ++){
ll p, y, ans = 0; cin >> p >> y;
memset(mn, 63, sizeof mn);
for(int j = 1; j <= n; j ++){
if(A[j] <= y && y <= B[j]){
//cout << "! " << j << '\n';
//cout << abs(X[j] - p) << '-' << '\n';
mn[T[j]] = min(mn[T[j]], abs(X[j] - p));
}
}
for(int j = 1; j <= k; j ++) ans = max(ans, mn[j]);
if(ans >= 1e18) ans = -1;
cout << ans << '\n';
}
return 0;
}
//! N.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... |