# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
46282 | ikura355 | Park (BOI16_park) | C++14 | 2566 ms | 1404 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//aiming for 58 marks
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
struct point {
double x, y, r;
};
int n,m;
double w,h;
point p[maxn];
int head[maxn];
int bad[10], con[10][10];
double cut(point x, point y) {
return sqrt((x.x-y.x)*(x.x-y.x) + (x.y-y.y)*(x.y-y.y));
}
int findhead(int x) {
if(head[x]==x) return x;
return head[x] = findhead(head[x]);
}
int main() {
scanf("%d%d%lf%lf",&n,&m,&w,&h);
for(int i=1;i<=n;i++) scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].r);
for(int tnum=1;tnum<=m;tnum++) {
double fat; int ent;
scanf("%lf%d",&fat,&ent); fat *= 2.0;
for(int i=1;i<=n+4;i++) head[i] = i;
//tree - tree
for(int i=1;i<=n;i++) {
for(int j=i+1;j<=n;j++) {
if(cut(p[i],p[j])-p[i].r-p[j].r < fat) {
head[findhead(i)] = findhead(j);
}
}
}
//tree - edge
for(int i=1;i<=n;i++) {
if(p[i].y-p[i].r < fat) head[findhead(i)] = findhead(n+1);
if(w-p[i].x-p[i].r < fat) head[findhead(i)] = findhead(n+2);
if(h-p[i].y-p[i].r < fat) head[findhead(i)] = findhead(n+3);
if(p[i].x-p[i].r < fat) head[findhead(i)] = findhead(n+4);
}
//connection
int id = 0;
for(int i=n+1;i<=n+4;i++) {
for(int j=i+1;j<=n+4;j++) {
bad[++id] = findhead(i)==findhead(j);
}
}
for(int i=1;i<=4;i++) for(int j=1;j<=4;j++) con[i][j] = 1;
if(bad[1] || bad[2] || bad[3]) con[1][2] = con[2][1] = 0;
if(bad[2] || bad[3] || bad[4] || bad[5]) con[1][3] = con[3][1] = 0;
if(bad[3] || bad[5] || bad[6]) con[1][4] = con[4][1] = 0;
if(bad[1] || bad[4] || bad[5]) con[2][3] = con[3][2] = 0;
if(bad[1] || bad[2] || bad[5] || bad[6]) con[2][4] = con[4][2] = 0;
if(bad[2] || bad[4] || bad[5]) con[3][4] = con[4][3] = 0;
//answer
for(int i=1;i<=4;i++) if(con[ent][i]) printf("%d",i);
printf("\n");
}
}
컴파일 시 표준 에러 (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... |