1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| #include<algorithm> #include<iostream> #include<iomanip> #include<cstring> #include<cstdlib> #include<vector> #include<cstdio> #include<cmath> #include<queue> using namespace std; typedef long long LL; inline const int Get_Int() { int num=0,bj=1; char x=getchar(); while(x<'0'||x>'9') { if(x=='-')bj=-1; x=getchar(); } while(x>='0'&&x<='9') { num=num*10+x-'0'; x=getchar(); } return num*bj; } const int maxn=6005; struct Edge { int from,to; LL dist; }; vector<Edge>edges[maxn]; void AddEdge(int x,int y,LL v) { edges[x].push_back((Edge) { x,y,v }); } int n,m,k,vst[maxn],From[maxn]; LL dist[maxn],x[maxn],y[maxn],ans=0; LL Dist(int a,int b) { if(a>k||b>k)return (y[a]-y[b])*(y[a]-y[b]); return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]); } void Prim() { for(int i=1; i<=k+2; i++)dist[i]=1e17; dist[k+1]=0; for(int i=1; i<=k+2; i++) { LL Min=1e17; int id=0; for(int j=1; j<=k+2; j++) if(!vst[j]&&dist[j]<Min) { Min=dist[j]; id=j; } vst[id]=1; if(From[id]) { LL d=Dist(id,From[id]); AddEdge(id,From[id],d); AddEdge(From[id],id,d); } for(int j=1; j<=k+2; j++) { LL d=Dist(id,j); if(!vst[j]&&d<dist[j]) { dist[j]=d; From[j]=id; } } } } void Dfs(int Now,int father,LL Max) { if(Now==k+2) { ans=Max; return; } for(auto& e:edges[Now]) { int Next=e.to; if(Next==father)continue; Dfs(Next,Now,max(Max,e.dist)); } } int main() { n=Get_Int(); m=Get_Int(); k=Get_Int(); for(int i=1; i<=k; i++) { x[i]=Get_Int(); y[i]=Get_Int(); } y[k+2]=m; Prim(); Dfs(k+1,0,0); printf("%0.8lf\n",sqrt(ans)/2); return 0; }
|