标签:des style blog http color io os ar java
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3881 Accepted Submission(s): 1346
#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <map> #include <cmath> using namespace std; #define eps 1e-5 const int N = 210; const int M = 400010; int n , m ; int st[N] , top ; bool mark[N]; int eh[N] , et[M] , nxt[M] , tot ; struct node { double x , y ; }e[N]; void init() { tot = 0 ; memset( eh , -1 , sizeof eh ); memset( mark , false , sizeof mark ); } void addedge( int u , int v ){ et[tot] = v , nxt[tot] = eh[u] , eh[u] = tot ++ ; et[tot] = u , nxt[tot] = eh[v] , eh[v] = tot ++ ; } bool dfs( int u ) { if( mark[u] ) return true; if( mark[u^1] ) return false; mark[u] = true ; st[top++] = u ; for( int i = eh[u] ; ~i ; i = nxt[i] ){ int v = et[i]; if( !dfs(v^1) ) return false; } return true; } bool solve() { for(int i = 0 ; i < 2 * n ; i += 2 ){ if( !mark[i] && !mark[i+1] ){ top = 0 ; if( !dfs(i) ){ while( top > 0 ) mark[ st[--top] ] = false; if( !dfs(i+1) ) return false ; } } } return true; } inline double dis( int i , int j ) { return sqrt( ( e[i].x - e[j].x ) * ( e[i].x - e[j].x ) + ( e[i].y - e[j].y ) * ( e[i].y - e[j].y ) ) ; } bool test( double DIS ) { init(); for( int i = 0 ; i < 2 * n ; i += 2 ){ for( int j = i + 2 ; j < 2 * n ; j += 2 ){ if( dis( i , j ) < DIS )addedge( i , j ); if( dis( i , j^1 ) < DIS )addedge( i , j^1 ); if( dis( i^1 , j ) < DIS )addedge( i^1 , j ) ; if( dis( i^1 , j^1 ) < DIS )addedge( i^1 , j^1 ); } } return solve(); } int main() { #ifdef LOCAL freopen("in.txt","r",stdin); #endif // LOCAL ios::sync_with_stdio(0); while( ~scanf("%d",&n) ){ for( int i = 0 ; i < 2 * n ; ++i ){ scanf("%lf%lf",&e[i].x,&e[i].y); } double l = 0.0 , r = sqrt( pow(20000.0,2.0) + pow(20000.0,2.0) ); while( l + eps <= r ){ double m = ( l + r ) / 2.0 ; if( test(m) ) l = m ; else r = m - eps ; } printf("%.2lf\n",l/2); } }
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/hlmark/p/4019566.html