HDU 3622 Bomb Game (二分+2-sat,4级 )
来源:互联网 发布:mac口红吧怎么看真假 编辑:程序博客网 时间:2024/06/06 01:06
E - Bomb Game
Crawling in process...Crawling failedTime Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uAppoint description:
Description
Robbie is playing an interesting computer game. The game field is an unbounded 2-dimensional region. There are N rounds in the game. At each round, the computer will give Robbie two places, and Robbie should 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 should 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.
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.
Input
The 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, 10000].
Output
Output one float number for each test case, indicating the best possible score. The result should be rounded to two decimal places.
Sample Input
21 1 1 -1-1 -1 -1 121 1 -1 -11 -1 -1 1
Sample Output
1.411.00
#include<cstdio>#include<cstring>#include<iostream>#define FOR(i,a,b) for(int i=a;i<=b;++i)#define clr(f,z) memset(f,z,sizeof(f))using namespace std;const int mm=410;const double oo=2e4+9;const double eps=1e-6;class Edge{ public:int v,next;};class cicle{ public:double x,y,xx,yy;}f[mm];int n;class TWO_SAT{public: int dfn[mm],e_to[mm],stack[mm]; Edge e[mm*mm*2]; int edge,head[mm],top,dfs_clock,bcc; void clear() { edge=0;clr(head,-1); } void add(int u,int v) { e[edge].v=v;e[edge].next=head[u];head[u]=edge++; } void add_my(int x,int xval,int y,int yval) { x=x+x+xval;y=y+y+yval; add(x,y); } void add_clause(int x,int xval,int y,int yval) {///x or y x=x+x+xval; y=y+y+yval; add(x^1,y);add(y^1,x); } void add_con(int x,int xval)//x is xval { x=x+x+xval; add(x^1,x); } int tarjan(int u) { int lowu,lowv; lowu=dfn[u]=++dfs_clock; int v; stack[top++]=u; for(int i=head[u];~i;i=e[i].next) { v=e[i].v; if(!dfn[v]) { lowv=tarjan(v); lowu=min(lowv,lowu); } else if(e_to[v]==-1)//in stack lowu=min(lowu,dfn[v]); } if(dfn[u]==lowu) { ++bcc; do{ v=stack[--top]; e_to[v]=bcc; }while(v!=u); } return lowu; } bool find_bcc(int n) { clr(e_to,-1); clr(dfn,0); bcc=dfs_clock=top=0; FOR(i,0,2*n-1) if(!dfn[i]) tarjan(i); for(int i=0;i<2*n;i+=2) if(e_to[i]==e_to[i^1])return 0; return 1; } bool build(double x) { clear(); FOR(i,1,n) FOR(j,i+1,n) FOR(k,0,1)FOR(l,0,1) if(intersex(i,k,j,l,x+x)) { add_clause(i-1,k^1,j-1,l^1); add_clause(j-1,l^1,i-1,k^1); } return find_bcc(n*2); } bool intersex(int i,int a,int j,int b,double mid) { double x,y,xx,yy,dis; if(a)x=f[i].xx,y=f[i].yy; else x=f[i].x,y=f[i].y; if(b)xx=f[j].xx,yy=f[j].yy; else xx=f[j].x,yy=f[j].y; dis=(x-xx)*(x-xx)+(y-yy)*(y-yy); mid*=mid; return dis<mid; }}two;char s[44];int main(){ int a,b,c,d; while(~scanf("%d",&n)) { FOR(i,1,n) { scanf("%lf%lf%lf%lf",&f[i].x,&f[i].y,&f[i].xx,&f[i].yy); } double l=0,r=oo,mid; while(r-l>eps) { mid=(l+r)/2; if(two.build(mid)) l=mid; else r=mid; } //cout<<(l+r)/2<<endl; printf("%.2lf\n",(l+r)/2); } return 0;}
- hdu 3622 Bomb Game(2-sat,二分,4级)
- HDU 3622 Bomb Game (二分+2-sat,4级 )
- hdu 3622 Bomb Game#2-sat+二分
- hdu 3622 Bomb Game (二分+2-sat)
- HDU 3622 Bomb Game(2-SAT+二分)
- HDU 3622 Bomb Game (二分+2-SAT)
- HDU 3622 Bomb Game 二分 + 2-sat
- hdu 3622 Bomb Game(二分+2-sat)
- |Hdu 3622|2-SAT|二分|Bomb Game
- Hdu 3622 Bomb Game 2-SAT+二分
- hdu 3622 Bomb Game(二分+2-sat判定)
- HDU 3622 Bomb Game( 二分查找+2-SAT )
- HDU 3622 Bomb Game(2-SAT + 二分)
- hdu 3622 Bomb Game(2-SAT 二分)
- HDU 3622 Bomb Game(二分+2-sat)
- hdu 3622 Bomb Game(2-SAT,二分)
- HDU 3622 Bomb Game(2-SAT+二分)
- HDU-3622-Bomb Game(2-SAT+二分)
- 俞敏洪+马云+牛根生+史玉柱经典语录
- Ubuntu下Samba服务器的搭建
- 一天之内可以完成的事
- 如何合并apk和odex文件
- poj 1696 Space Ant(计算几何)
- HDU 3622 Bomb Game (二分+2-sat,4级 )
- EZ-USB开发笔记(三)——内存安排
- 四位计算机的原理及其实现
- 锋利的jquery-jQuery文字提示
- 黑马程序员 IO流
- windows 8 store app 百度新闻快速浏览器 隐私声明
- MessageBox
- POJ 2296 Map Labeler (二分+2-sat,4级)
- uva 409 Excuses, Excuses!