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>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define int long long
signed main() {
int N, K, Q, L, Y;
cin >> N >> K >> Q;
vector<int> X(N), T(N), A(N), B(N);
for (int i = 0; i < N; i++) cin >> X[i] >> T[i] >> A[i] >> B[i];
unordered_set<int> types;
for (int i = 0; i < N; i++) types.insert(T[i]);
while (Q--) {
cin >> L >> Y;
unordered_map<int, int> stores;
for (int i = 0; i < N; i++) {
if (A[i] <= Y && Y <= B[i]) {
stores[T[i]] = max(abs(L - X[i]), stores[T[i]]);
}
}
if (stores.size() < types.size()) {
cout << "-1\n";
continue;
}
int M = -1;
for (pair<int, int> x: stores) {
M = max(M, x.second);
}
cout << M << '\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... |