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>
#define sz(v) v.size()
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define x first
#define y second
#define int long long
#define nl "\n"
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair <ll, ll> pii;
const int N = (int)3e5 + 7;
const int M = (int)15e6 + 7;
const ll MOD = (ll)1e9 + 7;
const int inf = (ll)1e9 + 7;
const ll INF = (ll)3e18 + 7;
pii dir[] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
int n, q, k, x[N], a[N], b[N], t[N];
vector<pair<int, pii> > g[N];
void solve() {
cin >> n >> k >> q;
for(int i = 1; i <= n; ++i) {
cin >> x[i] >> t[i] >> a[i] >> b[i];
g[t[i]].pb({x[i], {a[i], b[i]}});
}
while(q--) {
int l, x;
cin >> l >> x;
int ans = -1;
for(int i = 1; i <= k; ++i) {
int cur = inf;
for(auto e : g[i]) {
int p = e.x, L = e.y.x, R = e.y.y;
if(x >= L && x <= R) cur = min(cur, abs(p - l));
}
ans = max(ans, cur);
}
cout << (ans == inf ? -1 : ans) << nl;
}
}
signed main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
int test = 1;
//cin >> test;
for(int i = 1; i <= test; ++i) {
//cout << "Case " << i << ": ";
solve();
}
return 0;
}
/*
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
*/
/*
2 1 3
1 1 1 4
1 1 2 6
1 3
1 5
1 7
*/
/*
1 1 1
100000000 1 1 1 1
1 1
*/
# | 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... |