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;
#define rep(i,a,b) for(int i=a; i<int(b); i++)
int main() {
int n,q,k;
cin >> n >> k >> q;
vector<vector<int> > stores(n);
rep (i,0,n) {
int x,t,a,b;
cin >> x >> t >> a >> b;
stores[i]={x,t,a,b};
}
vector< pair<int,int> > queries(q);
rep (i,0,q) {
int l,y;
cin >> l >> y;
queries[i]=make_pair(l,y);
}
vector <set < vector<int> > > types(k);
rep (i,0,n) {
int t=stores[i][1]-1;
types[t].insert(stores[i]);
}
rep (i,0,q) {
int dist=0;
int l,y;
l=queries[i].first;
y=queries[i].second;
rep (i,0,k) {
int mindist=1e9;
for (auto a:types[i]) {
if (a[2]<=y && a[3]>=y)
mindist=min(mindist,abs(a[0]-l));
}
dist=max(dist,mindist);
}
if (dist==1e9) cout << -1 << endl;
else cout << dist << 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... |