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 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.
 
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
2
1 1 1 -1
-1 -1 -1 1
 
2
1 1 -1 -1
1 -1 -1 1
 
Sample Output
1.41
1.00
 
Source
 
 
距离最少值尽量大,,典型的二分 , 加上每个bomb有2种放法(只能取任意一种), 就是一个2-sat.
 
 注意一下精度,这里会卡一下。1e-4 可以过了
 
 
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <map>
#include <cmath> using namespace std; #define eps 1e-5
const int N = ;
const int M = ; 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 = ;
memset( eh , - , 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^] ) return false;
mark[u] = true ;
st[top++] = u ;
for( int i = eh[u] ; ~i ; i = nxt[i] ){
int v = et[i];
if( !dfs(v^) ) return false;
}
return true;
} bool solve()
{
for(int i = ; i < * n ; i += ){
if( !mark[i] && !mark[i+] ){
top = ;
if( !dfs(i) ){
while( top > ) mark[ st[--top] ] = false;
if( !dfs(i+) ) 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 = ; i < * n ; i += ){
for( int j = i + ; j < * n ; j += ){
if( dis( i , j ) < DIS )addedge( i , j );
if( dis( i , j^ ) < DIS )addedge( i , j^ );
if( dis( i^ , j ) < DIS )addedge( i^ , j ) ;
if( dis( i^ , j^ ) < DIS )addedge( i^ , j^ );
}
}
return solve();
} int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif // LOCAL
ios::sync_with_stdio(); while( ~scanf("%d",&n) ){
for( int i = ; i < * 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/);
}
}

HDU 3622 Bomb Game(2-sat)的更多相关文章

  1. HDU 3622 Bomb Game(二分+2-SAT)

    Bomb Game Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. HDU 5860 Death Sequence(死亡序列)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  3. HDU 5877 Weak Pair(弱点对)

    HDU 5877 Weak Pair(弱点对) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Jav ...

  4. HDU 5813 Elegant Construction(优雅建造)

    HDU 5813 Elegant Construction(优雅建造) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65 ...

  5. HDU 5818 Joint Stacks(联合栈)

    HDU 5818 Joint Stacks(联合栈) Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Ja ...

  6. HDU 2222 Keywords Search(查询关键字)

    HDU 2222 Keywords Search(查询关键字) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K ...

  7. HDU 3549 Flow Problem(最大流)

    HDU 3549 Flow Problem(最大流) Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...

  8. HDU 3622 Bomb Game(2-sat)

    HDU 3622 Bomb Game 题目链接 题意:求一个最大半径,使得每一个二元组的点任选一个,能够得到全部圆两两不相交 思路:显然的二分半径,然后2-sat去判定就可以 代码: #include ...

  9. HDU 4548 美素数(打表)

    HDU  4548  美素数(打表)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88159#problem/H 题目 ...

随机推荐

  1. 使用wkhtmltopdf工具生成pdf

    背景:将前台页面转换成pdf文档保存到服务器 最开始计划使用canvas2pdf在前端进行生成.但是canva2pdf转换的pdf有严重的失真问题,然后决定使用wkhtmltopdf工具进行生成. 思 ...

  2. tensorflow的reshape操作tf.reshape()

    在处理图像数据的时候总会遇到输入图像的维数不符合的情况,此时tensorflow中reshape()就很好的解决了这个问题. 更为详细的可以参考官方文档说明: numpy.reshape reshap ...

  3. c++求中位数

    #include <iostream> #include <cassert> #include <stack> #include <math.h> us ...

  4. Sass-数据类型

    Sass和JavaScript语言类似,也具有自己的数据类型,在Sass中包含一下几种数据类型 数字:如,1,2,13,10px; 字符串: 有引号字符串或无引号字符串,如,“foo”,"b ...

  5. ivew select组件 DatePicker组件的清空

    <Form ref="formInline" :model="formInline" :rules="ruleInline" inli ...

  6. spring Boot 简单的登录功能,利用了jdbcTemplate.class完成sql语句的执行,无需service层、dao层和.xml文件

    1.搭建SpringBoot项目首先我们先在IDEA上创建一个SpringBoot的Web项目(1)file ——> new ——> project——> Spring Initia ...

  7. Vue-cli 项目设置每个页面标题

    页面标题 在vue-router页面配置中添加meta的title信息,配合vue-router的beforeEach注册一个前置守卫用户获取到页面配置的title const title = '移动 ...

  8. boost Filesystem

    The library Boost.Filesystem makes it easy to work with files and directories. Paths Paths can be bu ...

  9. CALayer的mask属性

    可以对图层按path进行指定裁剪 //#import "ViewController.h" // //@interface ViewController () // //@end ...

  10. spring-boot整合Dubbo分布式架构案例

    1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 3.2.5 2.项目文件目录 3.Maven Plugin管理 总项目 pom.xml配置代码: &l ...