用read()会挂
二分半径,显然最优的是所有原都用这个最小半径,然后2-SAT把相交的圆建图,跑tarjan判一下可行性即可
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=205;
int n,h[N],cnt,dfn[N],low[N],tot,s[N],top,bl[N],col;
bool v[N];
struct qwe
{
int ne,to;
}e[N*N*8];
struct dian
{
double x,y;
}a[N],b[N];
double dis(dian a,dian b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int read()
{
int r=0,f=1;
char p=getchar();
while(p>='9'||p<'0')
{
if(p=='-')
f=-1;
p=getchar();
}
while(p>='0'&&p<='9')
{
r=r*10+p-48;
p=getchar();
}
return r*f;
}
void add(int u,int v)
{//cerr<<u<<" "<<v<<endl;
cnt++;
e[cnt].ne=h[u];
e[cnt].to=v;
h[u]=cnt;
}
void tarjan(int u)
{
dfn[u]=low[u]=++tot;
v[s[++top]=u]=1;
for(int i=h[u];i;i=e[i].ne)
{
if(!dfn[e[i].to])
{
tarjan(e[i].to);
low[u]=min(low[u],low[e[i].to]);
}
else if(v[e[i].to])
low[u]=min(low[u],dfn[e[i].to]);
}
if(low[u]==dfn[u])
{
col++;
while(s[top]!=u)
{
bl[s[top]]=col;
v[s[top--]]=0;
}
bl[s[top]]=col;
v[s[top--]]=0;
}
}
bool ok(double w)
{//cerr<<w<<endl;
memset(h,0,sizeof(h));
memset(v,0,sizeof(v));
memset(dfn,0,sizeof(dfn));
cnt=0,tot=0,top=0,col=0;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
{
if(dis(a[i],a[j])<2.0*w)
add(i,j+n),add(j,i+n);
if(dis(a[i],b[j])<2.0*w)
add(i,j),add(j+n,i+n);
if(dis(b[i],a[j])<2.0*w)
add(i+n,j+n),add(j,i);
if(dis(b[i],b[j])<2.0*w)
add(i+n,j),add(j+n,i);
}
for(int i=1;i<=n+n;i++)
if(!dfn[i])
tarjan(i);
for(int i=1;i<=n;i++)
if(bl[i]==bl[i+n])
return 0;
return 1;
}
int main()
{
while(~scanf("%d",&n))
{
for(int i=1;i<=n;i++)
scanf("%lf%lf%lf%lf",&a[i].x,&a[i].y,&b[i].x,&b[i].y);
double l=0,r=1e4,ans=0;
while(r-l>1e-3)
{
double mid=(l+r)/2;
if(ok(mid))
l=mid,ans=mid;
else
r=mid;
}
printf("%.2f
",ans);
}
return 0;
}