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 int long long
signed main(){
int n, k, q;
cin >> n >> k >> q;
int x[n], t[n], a[n], b[n];
for (int i=0; i<n; i++){
cin >> x[i] >> t[i] >> a[i] >> b[i];
}
while(q--){
int l, y;
cin >> l >> y;
bool isopen[n], hastype[k];
memset(isopen, false, sizeof(isopen));
memset(hastype, false, sizeof(hastype));
map<int, int> mp; //mp[type] = min dist
for (int i=0; i<n; i++){
if(y>=a[i] && y<=b[i]){ // shop is open
isopen[i] = true;
if(hastype[t[i]-1]==true) mp[t[i]-1] = min(mp[t[i]-1], abs(x[i]-l));
else{
mp[t[i]-1] = abs(x[i]-l);
hastype[t[i]-1] = true;
}
}
}
bool done = false;
for (int i=0; i<k; i++){
if(hastype[i]==false){ //not all types open
cout << "-1\n";
done = true;
break;
}
}
if(done==false){
int inconv = 0;
for (int i=0; i<k; i++){
inconv = max(inconv, mp[i]);
}
cout << inconv << "\n";
}
}
return 0;
}
# | 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... |