Description
Input
Output
Sample Input
2 1 1 1 -1 -1 -1 -1 1 2 1 1 -1 -1 1 -1 -1 1
Sample Output
1.41 1.00
每次选择从2个炸弹中选择放置一个炸弹
每个炸弹的爆炸半径可控问如何放置让爆炸半径最大
两个炸弹爆炸范围不相交
二分半径范围即可
ACcode:
#include <map> #include <queue> #include <cmath> #include <cstdio> #include <cstring> #include <stdlib.h> #include <iostream> #include <algorithm> #define maxn 100000 #define esp 1e-5 using namespace std; struct Node{int to,next;}edge[maxn]; int head[maxn],tot; void add(int u,int v){edge[tot].to=v;edge[tot].next=head[u];head[u]=tot++;} int low[maxn],dfn[maxn],Stack[maxn],Belong[maxn]; bool Instack[maxn]; int Index,scc,top; void init(){tot=0;memset(head,-1,sizeof(head));} void tarjan(int u){ int v; low[u]=dfn[u]=++Index; Stack[top++]=u; Instack[u]=true; for(int i=head[u];i!=-1;i=edge[i].next){ v=edge[i].to; if(!dfn[v]){tarjan(v);low[u]=min(low[u],low[v]);} else if(Instack[v]&&low[u]>dfn[v])low[u]=dfn[v]; } if(low[u]==dfn[u]){ scc++; do{ v=Stack[--top]; Instack[v]=false; Belong[v]=scc; }while(v!=u); } } bool solve(int n){ memset(dfn,0,sizeof(dfn)); memset(Instack,false,sizeof(Instack)); Index=scc=top=0; for(int i=0;i<n;++i)if(!dfn[i])tarjan(i); for(int i=0;i<n;i+=2)if(Belong[i]==Belong[i+1])return false; return true; } struct P{int x,y;void in(){scanf("%d%d",&x,&y);}}; double dist(P a,P b){return sqrt((double)(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));} P my[maxn],a[maxn],b[maxn]; int main(){ int n,x1,x2,y1,y2,N; while(~scanf("%d",&n)){ N=n<<1; for(int i=0;i<n;++i){ my[i*2].in(); my[i*2+1].in(); } double lf=0,rt=40000,mid; while(lf<=rt-esp){ mid=(lf+rt)/2; init(); for(int i=0;i<N-1;++i){ for(int j=2+i-i%2;j<N;++j){ if(dist(my[i],my[j])<2*mid){ add(i,j^1); add(j,i^1); } } } if(solve(N))lf=mid; else rt=mid; } printf("%.2lf\n",lf); } return 0; }