이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |