HDU 3622 bomb game

Source: Internet
Author: User
Tags float number rounds

Bomb game

Time Limit: 10000/3000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 3881 accepted submission (s): 1346


Problem descriptionrobbie is playing an interesting computer game. the game field is an unbounded 2-dimen1_region. there are n rounds in the game. at each round, the computer will give Robbie two places, and Robbie shoshould choose one of them to put a bomb. the explosion area of the bomb is a circle whose center is just the chosen place. robbie can control the power of the bomb, that is, he can control the radius of each circle. A strange requirement is that there shoshould be no common area for any two circles. the final score is the minimum radius of all the N circles.
Robbie has cracked the game, and he has known all the candidate places of each round before the game starts. Now he wants to know the maximum score he can get with the optimal strategy.

 

Inputthe first line of each test case is an integer N (2 <= n <= 100), indicating the number of rounds. then n lines follow. the I-th line contains four integers x1i, y1i, x2i, y2i, indicating that the coordinates of the two candidate places of the I-th round are (x1i, y1i) and (x2i, y2i ). all the coordinates are in the range [-10000,100 00].

 

Outputoutput one float number for each test case, indicating the best possible score. The result shocould be rounded to two decimal places.

 

Sample input21 1 1-1-1-1-1 1 21 1-1-11-1-1 1 1

 

Sample output1.411.00

 

Source2010 Asia Regional Tianjin site -- the minimum online contest distance value is as large as possible. A typical binary method. In addition, each bomb has two release methods (only one can be used ), is a 2-sat.
#include <iostream>#include <cstdio>#include <cstring>#include <stack>#include <map>#include <cmath>using namespace std;#define eps 1e-5const 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);    }}

 

 

HDU 3622 bomb game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.