C++
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
struct Pos{
int x;
int y;
};
struct Q_info{
int x;
int y;
int i;
int t;
};
int dist[1010][1010];
int N,K;
Pos pos[1010];
int check[1010];
queue<Q_info> q;
int serch(int L){
while(!q.empty()){
Q_info info=q.front();
q.pop();
if(info.x==10000&&info.y==10000){
return 1;
}
if(info.t<=K){
for(int i=1;i<=N+2;i++){
if(check[i]==1||i==info.i)
continue;
if(dist[info.i][i]<=L){
check[i]=1;
q.push({pos[i].x,pos[i].y,i,info.t+1});
}
}
}
}
return 0;
}
int main()
{
scanf("%d %d",&N,&K);
pos[1].x=0;
pos[1].y=0;
for(int i=2;i<=N+1;i++){
scanf("%d %d",&pos[i].x,&pos[i].y);
}
pos[N+2].x=10000;
pos[N+2].y=10000;
for(int i=1;i<=N+2;i++){
for(int j=1;j<=N+2;j++){
if(i==j)
continue;
//int a=sqrt((double)(pow(pos[i].x-pos[j].x,2)+pow(pos[i].y-pos[j].y,2)));
//dist[i][j]=a/10+1;
dist[i][j]=ceil(sqrt((double)(pow(pos[i].x-pos[j].x,2)+pow(pos[i].y-pos[j].y,2))) / 10.0);
}
}
int lb=1,ub=1415;
while(lb<ub){
int c = (ub+lb)/2;
while( !q.empty() ) q.pop();
q.push({0,0,1,0});
memset(check,0,sizeof(check));
check[1]=1;
int a=serch(c);
if(a==1){
ub=c;
}else{
lb=c+1;
}
}
printf("%d",ub);
return 0;
}
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
공지 | 안내사항 | 관리자 | 2019.12.21 | 163 |
74 | 9663 | 관리자 | 2019.12.21 | 114 |
73 | 9345 | 관리자 | 2020.04.11 | 150 |
72 | 9019 | 관리자 | 2019.12.21 | 113 |
71 | 7569 | 관리자 | 2019.12.21 | 113 |
70 | 6987 | 관리자 | 2019.12.21 | 113 |
69 | 5842 | 관리자 | 2020.04.11 | 151 |
68 | 5625 | 관리자 | 2019.12.21 | 109 |
67 | 5419 | 관리자 | 2020.04.11 | 155 |
66 | 3392 | 관리자 | 2020.04.11 | 156 |
65 | 3019 | 관리자 | 2019.12.21 | 111 |
64 | 2933 | 관리자 | 2019.12.21 | 112 |
63 | 2931 | 관리자 | 2019.12.21 | 111 |
62 | 2836 | 관리자 | 2019.12.21 | 110 |
61 | 2667 | 관리자 | 2019.12.21 | 113 |
60 | 2636 | 관리자 | 2019.12.21 | 113 |
59 | 2629 | 관리자 | 2020.04.11 | 146 |
58 | 2615 | 관리자 | 2019.12.21 | 111 |
57 | 2610 | 관리자 | 2020.04.11 | 146 |
56 | 2606 | 관리자 | 2019.12.21 | 111 |
» | 2585 | 관리자 | 2019.12.21 | 113 |
54 | 2578 | 관리자 | 2019.12.21 | 111 |
53 | 2573 | 관리자 | 2020.04.11 | 151 |
52 | 2557 | 관리자 | 2019.12.21 | 111 |
51 | 2512 | 관리자 | 2019.12.21 | 111 |
50 | 2504 | 관리자 | 2020.04.11 | 147 |
49 | 2481 | 관리자 | 2019.12.21 | 112 |
48 | 2478 | 관리자 | 2020.04.11 | 148 |
47 | 2473 | 관리자 | 2020.04.11 | 153 |
46 | 2470 | 관리자 | 2020.04.11 | 151 |