Hdu-3622-bomb Game (2-sat+ two points)

Source: Internet
Author: User
Tags float number rounds

Bomb GameTime limit:10000/3000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4897 Accepted Submission (s): 1750


Problem Descriptionrobbie is playing an interesting computer game. The game field is a unbounded 2-dimensional region. There is N rounds in the game. At each round, the computer would give Robbie the places, and Robbie should choose one of the them to put a bomb. The explosion area of the bomb is a circle whose center are just the chosen place. Robbie can control the power of the bomb, that's, he can control the radius of each circle. A Strange requirement is this there should be no common area for any of the circles. The final score is the minimum radius of all the N circles.
Robbie has cracked the game, and he have 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 all test case was an integer n (2 <= n <=), 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 and candidate of th E i-th round is (x1i, y1i) and (X2i, y2i). All the coordinates is in the range [-10000, 10000].

Outputoutput one float number for each test case, indicating the best possible score. The result should is rounded to both decimal places.

Sample Input
21 1 1-1-1-1-1 121 1-1-11-1-1 1

Sample Output
1.411.00

give n to the coordinates where the bombs can be placed, Each pair can only choose one, each bomb explodes the radius of the range is the same,

control the radius of the explosion so that all of the explosion range is not equal to solve this maximum radius.

Direct two-point answer, run a wave 2-sat just fine.




#include <bits/stdc++.h> #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm>using namespace std;const int maxn = 1e5+7;const double eps = 1e-5;int x[maxn],y[ma    xn];struct node{int v,next;} edge[maxn];int head[maxn],index;void Add_edge (int u,int v) {edge[index].v=v;    Edge[index].next=head[u]; head[u]=index++;}    int dfn[maxn],low[maxn],stack_[maxn],in_stack[maxn],belong[maxn];int cir,top,temp;void Tarjan (int u) {int p;    Dfn[u]=low[u]=++temp;    In_stack[u]=1;    Stack_[top++]=u;        for (int i=head[u]; i+1; i=edge[i].next) {int v=edge[i].v; if (!            Dfn[v]) {Tarjan (v);        Low[u]=min (Low[u],low[v]);    } else if (In_stack[v]) low[u]=min (Low[u],dfn[v]);        } if (Low[u]==dfn[u]) {++cir;            do {p=stack_[--top];            in_stack[p]=0;        Belong[p]=cir;    } while (P!=u); }}double Dist (inT I,int j) {return sqrt ((double) (X[i]-x[j]) * (X[i]-x[j]) + (Y[i]-y[j]) * (Y[i]-y[j]);}    int main () {int n,m; while (scanf ("%d", &n)!=eof) {for (int i=0; i<n<<1; ++i) scanf ("%d%d", &x[i],&y[i])        ;        Double ans;        Double L=0.0,r=40000.0,mid;            while (r-l>=eps) {mid= (l+r)/2.0;            temp=cir=top=index=0;            memset (dfn,0,sizeof (DFN));            memset (head,-1,sizeof (head));            memset (in_stack,0,sizeof (in_stack));            Memset (Belong,0,sizeof (belong));                    for (int i=0, i<n<<1; ++i) for (int j=i+1; j<n<<1; ++j) {                    if (j-i==1&&i&1==0) continue;                        if (Dist (i,j) <mid*2.0) {Add_edge (j^1,i);                    Add_edge (I^1,J); }} for (int i=0; i<n<<1; ++i) if (!      Dfn[i]) Tarjan (i);      int flag=0;                    for (int i=0; i<n; ++i) if (belong[i<<1]==belong[(i<<1) ^1]) {                    flag=1;                Break            } if (!flag) {ans=mid;l=mid;}        else R=mid;    } printf ("%.2lf\n", ans); } return 0;}





Hdu-3622-bomb Game (2-sat+ two points)

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.