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;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int t = 1;
while (t--) {
int n, type, q;
cin >> n >> type >> q;
vector<long long> loc(n+3), tp(n + 3), st(n + 3), ed(n + 3);
for (int i = 0; i < n; i++) {
cin >> loc[i] >> tp[i] >> st[i] >> ed[i];
tp[i]--;
}
for (int i = 0; i < q; i++) {
int u, ti; cin >> u >> ti;
long long ans = -1;
vector<long long> cur_type(n, INT_MAX);
for (int j = 0; j < n; j++) {
if (st[j] <= ti && ti<=ed[j]) {
cur_type[tp[j]-1] = min(cur_type[tp[j]-1], abs(u - loc[j]));
}
}
for (auto& x : cur_type) {
ans = max(ans, x);
}
if (ans == INT_MAX) ans = -1;
cout << ans << 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... |