#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 100000000000000000
#define ff first
#define ss second
#define pii pair<int,int>
#define mod 998244353
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define osetp tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
#define one(x) __builtin_popcount(x)
#define fone(x) __builtin_clz(n)
#define fraction(x) cout<<setprecision(x)<<fixed
const int d8i[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int d4i[4] = {1, 0, -1, 0};
const int d4j[4] = {0, 1, 0, -1};
const int mxn = 1e5;
/*
4 2 4
3 1 1 10
9 2 2 4
7 2 5 7
4 1 8 10
5 3
5 6
5 9
1 10
*/
void solve( ) {
int n, k, q; cin >> n >> k >> q;
vector<array<int, 4>>a(n);
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
}
while (q--) {
int ans = -1;
int l, y; cin >> l >> y;
map<int, int>s;
for (int i = 0; i < n; i++) {
if (a[i][2] <= y and y <= a[i][3]) {
if (s.find(a[i][1]) == s.end()) {
s[a[i][1]] = abs(l - a[i][0]);
}
else {
s[a[i][1]] = min(abs(a[i][0] - l), s[a[i][1]]);
}
}
}
for (auto i : s) {
ans = max(ans, i.ss);
}
if (sz(s) != k) {
cout << -1 << '\n';
continue;
}
cout << ans << '\n';
}
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1; //cin >> t;
for (int i = 1; i <= t; i++) {
solve();
}
}
# | 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... |