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;
typedef long long ll;
typedef long double ld;
struct store {
int x, t, a, b;
store(int x, int t, int a, int b) : x(x), t(t), a(a), b(b) {}
};
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, k, q;
cin >> n >> k >> q;
vector <store> kek;
for (int i = 0; i < n; ++i) {
int x, t, a, b;
cin >> x >> t >> a >> b;
--t;
kek.emplace_back(x, t, a, b);
}
while (q--) {
int l, y;
cin >> l >> y;
vector <int> mx(k, (int)-1e9);
for (auto s : kek) {
if (s.a <= y && y <= s.b) {
mx[s.t] = max(mx[s.t], abs(l - s.x));
}
}
int ans = -1e9;
bool bad = false;
for (int i = 0; i < k; ++i) {
if (mx[i] < (int)-5e8) {
cout << "-1\n";
bad = true;
break;
}
ans = max(ans, mx[i]);
}
if (!bad) {
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... |