This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
const char nl = '\n';
void fastIO() {
ios::sync_with_stdio(false);
cin.tie(0);
}
int main() {
fastIO();
int N, K, Q;
cin>>N>>K>>Q;
// stores of each type
vector<pair<int, ii>> stores[K];
// {pos, {start, end}}
for (int i = 0; i < N; i++) {
int x, y, a, b;
cin>>x>>y>>a>>b;
x--; y--;
stores[y].pb({x, {a, b}});
}
for (int i = 0; i < Q; i++) {
int x, t;
cin>>x>>t;
x--;
vi nd(K, 1e9);
for (int j = 0; j < K; j++) {
for (pair<int, ii> p : stores[j]) {
if (p.se.fi <= t && t <= p.se.se)
nd[j] = min(nd[j], abs(p.fi - x));
}
}
int ans = -1;
for (int x : nd)
ans = max(ans, x);
// cout<<"ANSWER: ";
if (ans != 1e9)
cout<<ans<<endl;
else
cout<<-1<<endl;
}
}
# | 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... |