2 1 1 1 -1 -1 -1 -1 1 2 1 1 -1 -1 1 -1 -1 1
1.41 1.00
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib> 10 #include <string> 11 #include <set> 12 #include <stack> 13 #define LL long long 14 #define pii pair<int,int> 15 #define INF 0x3f3f3f3f 16 using namespace std; 17 const int maxn = 250; 18 const double exps = 1e-5; 19 struct arc{ 20 int to,next; 21 arc(int x = 0,int y = -1){ 22 to = x; 23 next = y; 24 } 25 }; 26 struct node{ 27 int x,y; 28 }; 29 node p[maxn]; 30 arc e[maxn*maxn*10]; 31 int head[maxn],tot,dfn[maxn],low[maxn],belong[maxn],scc,cnt,n; 32 bool instack[maxn]; 33 stack<int>stk; 34 void add(int u,int v){ 35 e[tot] = arc(v,head[u]); 36 head[u] = tot++; 37 } 38 double dis(const node &a,const node &b){ 39 double tmp = (a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y); 40 return sqrt(tmp); 41 } 42 void tarjan(int u){ 43 dfn[u] = low[u] = ++cnt; 44 stk.push(u); 45 instack[u] = true; 46 for(int i = head[u]; ~i; i = e[i].next){ 47 if(!dfn[e[i].to]){ 48 tarjan(e[i].to); 49 low[u] = min(low[u],low[e[i].to]); 50 }else if(instack[e[i].to]) low[u] = min(low[u],dfn[e[i].to]); 51 } 52 if(low[u] == dfn[u]){ 53 scc++; 54 int v; 55 do{ 56 v = stk.top(); 57 stk.pop(); 58 instack[v] = false; 59 belong[v] = scc; 60 }while(v != u); 61 } 62 } 63 bool solve(){ 64 while(!stk.empty()) stk.pop(); 65 for(int i = 0; i < maxn; i++){ 66 belong[i] = dfn[i] = low[i] = 0; 67 instack[i] = false; 68 } 69 scc = cnt = 0; 70 for(int i = 0; i < n<<1; i++) 71 if(!dfn[i]) tarjan(i); 72 for(int i = 0; i < n; i++) 73 if(belong[i<<1] == belong[i<<1|1]) return false; 74 return true; 75 } 76 int main() { 77 int x,y; 78 double low,high,mid; 79 while(~scanf("%d",&n)){ 80 for(int i = 0; i < n; i++) 81 scanf("%d %d %d %d",&p[i<<1].x,&p[i<<1].y,&p[i<<1|1].x,&p[i<<1|1].y); 82 low = 0; 83 high = 2000.0; 84 while(fabs(high - low) > exps){ 85 mid = (high + low)/2.0; 86 memset(head,-1,sizeof(head)); 87 for(int i = tot = 0; i < (n-1)<<1; i++){ 88 for(int j = i&1?i+1:i+2; j < n<<1; j++){ 89 if(dis(p[i],p[j]) < 2.0*mid){//i与j不能共存 90 add(i,j^1); 91 add(j,i^1); 92 } 93 } 94 } 95 if(solve()) low = mid; 96 else high = mid; 97 } 98 printf("%.2f\n",high); 99 } 100 return 0; 101 }