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; //cin >> t;
while (t--) {
int n, type, q;
cin >> n >> type >> q;
vector<long long> loc(n), tp(n), st(n), ed(n);
for (int i = 0; i < n; i++) {
cin >> loc[i] >> tp[i] >> st[i] >> ed[i];
}
for (int i = 0; i < q; i++) {
long long u, v; cin >> u >> v;
vector<long long> cur_type(type + 5, 0);
long long ans = 0;
for (int j = 0; j < n; j++) {
if(st[j]<=v && ed[j]>=v){
ans = max(ans, abs(u-loc[j]));
cur_type[tp[j]]++;
}
}
int ok = 1;
for (int p = 1; p <= type; p++) {
if (cur_type[p] == 0) ok = 0;
}
if (ok == 0) cout << "-1\n";
else 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... |