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 endl '\n'
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int ll
#define all(vec) vec.begin(), vec.end()
typedef long long ll;
using namespace std;
const int N = 410, mod = 1e9 + 7;
struct st{
int x, t, a, b;
};
int n, k, q;
vector<st> v(N);
signed main()
{
FAST;
cin >> n >> k >> q;
for(int i = 1; i <= n; i++) {
cin >> v[i].x >> v[i].t >> v[i].a >> v[i].b;
}
while(q--) {
int l, y;
cin >> l >> y;
int ans[k+1];
for(int i = 1; i <= k; i++) ans[i] = INT_MAX;
for(int i = 1; i <= n; i++) {
if(v[i].a <= y && v[i].b >= y) {
ans[v[i].t] = min(ans[v[i].t], abs(v[i].x - l));
}
}
int fin = 0;
for(int i = 1; i <= k; i++) {
fin = max(fin, ans[i]);
}
if(fin == INT_MAX) cout << -1 << endl;
else cout << fin << endl;
}
}
# | 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... |