# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
112137 | znfmxmrhlepf | 새 집 (APIO18_new_home) | C++14 | 5059 ms | 11324 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <iostream>
using namespace std;
typedef pair<int, int> pii;
struct pos{int x, t, a, b;};
const int MAX_n = 3*100000;
int n, q, k;
pos str[MAX_n+1];
int main(){
scanf("%d %d %d", &n, &k, &q);
vector<pii> locs;
for(int i=0; i<n; i++){
scanf("%d %d %d %d", &str[i].x, &str[i].t, &str[i].a, &str[i].b);
locs.push_back({str[i].x, i});
}
sort(locs.begin(), locs.end());
for(int i=0; i<q; i++){
int ql, qy;
scanf("%d %d", &ql, &qy);
bool typeFlag[MAX_n]={0,};
vector<int> locs_x;
for(int j=0; j<n; j++){
int idx = locs[j].second;
if((str[idx].a-qy)*(str[idx].b-qy) <= 0){ // store j exist
typeFlag[str[idx].t]=true;
locs_x.push_back(locs[j].first);
}
}
bool flag=true;
for(int j=1; j<=k; j++){
if(!typeFlag[j])
flag=false;
}
if(!flag){
cout << -1;
continue;
}
int lb;
lb = lower_bound(locs_x.begin(), locs_x.end(), ql)-locs_x.begin();
if(lb == 0)
printf("%d\n", locs_x[0]-ql);
else if(lb == locs_x.size())
printf("%d\b", ql - locs_x.back());
else printf("%d\n", max(locs_x[lb]-ql, ql-locs_x[lb-1]));
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |