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>
using namespace std;
#define ll long long
const int inf = 1e9;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, k, q;
cin >> n >> k >> q;
array<int, 4> a[n];
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
}
while (q--) {
int l, y;
cin >> l >> y;
vector<int> v[k + 1];
for (int i = 0; i < n; i++) {
if (a[i][2] <= y && y <= a[i][3]) {
v[a[i][1]].push_back(a[i][0]);
}
}
int mx = 0;
for (int i = 1; i <= k; i++) {
int mn = inf;
for (auto j : v[i]) {
mn = min(mn, abs(l - j));
}
mx = max(mx, mn);
}
if (mx == inf) {
cout << "-1\n";
} else {
cout << mx << '\n';
}
}
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... |