hdu 3622 Bomb Game(二分+2-sat)
来源:互联网 发布:还珠格格知画怎么怀孕 编辑:程序博客网 时间:2024/05/16 14:05
Problem 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
Source
2010 Asia Regional Tianjin Site —— Online Contest
题意:
给n对炸弹可以放置的位置(每个位置为一个二维平面上的点),每次放置炸弹是时只能选择这一对中的其中一个点,每个炸弹爆炸的范围半径都一样,控制爆炸的半径使得所有的爆炸范围都不相交(可以相切),求解这个最大半径
思路:首先二分最大半径值
然后2-sat构图判断其可行性,对于每两队位置(u,uu)和(v,vv),
如果u和v之间的距离小于2*id,也就是说位置u和位置v处不能同时
防止炸弹(两范围相交),所以连边(u,vv)和(v,uu),求解强连通分
量判断可行性.
代码:
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<stack>using namespace std;const int N=205;const int M=40005;const double ex=1e-3;struct node1{ double x,y;}point[N];struct node{ int now,next;}str[M];stack<int>s;int dfs[N],ins[N],belong[N],low[N];int head[N],tot,tol,ans;void init(){ memset(dfs,-1,sizeof(dfs)); memset(ins,0,sizeof(ins)); memset(head,-1,sizeof(head)); tot=0; tol=0; ans=0;}double dis(node1 a,node1 b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}void add(int x,int y){ str[tot].now=y; str[tot].next=head[x]; head[x]=tot++;}void tarjan(int x){ s.push(x); dfs[x]=low[x]=tol++; ins[x]=1; for(int i=head[x];i!=-1;i=str[i].next) { int y=str[i].now; if(dfs[y]==-1) { tarjan(y); low[x]=min(low[x],low[y]); } else if(ins[y]) { low[x]=min(low[x],dfs[y]); } } if(dfs[x]==low[x]) { while(1) { int q=s.top(); s.pop(); ins[q]=0; belong[q]=ans; if(x==q) break; } ans++; }}bool ok(int n){ for(int i=0;i<2*n;i++) if(dfs[i]==-1) { tarjan(i); } for(int i=0;i<2*n;i+=2) if(belong[i]==belong[i+1]) { return false; } return true;}int main(){ int n; while(~scanf("%d",&n)) { for(int i=0;i<n;i++) scanf("%lf%lf%lf%lf",&point[2*i].x,&point[2*i].y,&point[2*i+1].x,&point[2*i+1].y); double l=0,r=40000; while(r-l>=ex) { init(); double temp=(l+r)/2; for(int i=0;i<2*n-2;i++) { int t; if(i%2) t=i+1; else t=i+2; for(int j=t;j<2*n;j++) { if(dis(point[i],point[j])<2*temp) { add(i,j^1); add(j,i^1); } } } if(ok(n)) l=temp; else r=temp; } printf("%.2lf\n",l); } return 0;}
0 0
- 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,二分,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)
- 信息系统分析与设计课程心得
- tomcat http协议与ajp协议(8009端口)
- 商品的录入和窗口表格商品的显示
- 【bzoj 3534】 [SDOI2014] 重建
- 求二次根式(汇编浮点数指令fsqrt实现)
- hdu 3622 Bomb Game(二分+2-sat)
- linux ----- cp
- L3-001. 凑零钱【dp】
- yii2.0basic版的配置
- JAVA SDK 极光推送后台DEMO
- Mongodb PITR恢复
- SharePoint 2016 配置用户请求应用程序
- OpenResty(Nginx)+Lua+GraphicsMagick实现图片截图与缓存 二
- iptables 基本用法