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 int long long
using namespace std;
int n, k, q, i, l, y, cur, ans, x[300001], t[300001], a[300001], b[300001];
vector<pair<int, pair<int, int>>> g[300001];
signed main() {
cin.tie(0)->sync_with_stdio(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
cin >> n >> k >> q;
for (i = 1; i <= n; i++) {
cin >> x[i] >> t[i] >> a[i] >> b[i];
g[t[i]].push_back({x[i], {a[i], b[i]}});
}
while (q--) {
cin >> l >> y;
ans = 0;
for (i = 1; i <= k; i++) {
cur = 1e18;
for (auto j : g[i]) {
if (j.second.first <= y && y <= j.second.second) {
cur = min(cur, abs(l - j.first));
}
}
if (cur >= 1e17) {
ans = -1;
break;
}
ans = max(ans, cur);
}
cout << ans << "\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... |