HDU 3622 Bomb Game(2-sat)
Bomb Game
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3881 Accepted Submission(s): 1346
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.
#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)的更多相关文章
- HDU 3622 Bomb Game(二分+2-SAT)
Bomb Game Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- HDU 5860 Death Sequence(死亡序列)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 5877 Weak Pair(弱点对)
HDU 5877 Weak Pair(弱点对) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Jav ...
- HDU 5813 Elegant Construction(优雅建造)
HDU 5813 Elegant Construction(优雅建造) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65 ...
- HDU 5818 Joint Stacks(联合栈)
HDU 5818 Joint Stacks(联合栈) Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Ja ...
- HDU 2222 Keywords Search(查询关键字)
HDU 2222 Keywords Search(查询关键字) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K ...
- HDU 3549 Flow Problem(最大流)
HDU 3549 Flow Problem(最大流) Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
- HDU 3622 Bomb Game(2-sat)
HDU 3622 Bomb Game 题目链接 题意:求一个最大半径,使得每一个二元组的点任选一个,能够得到全部圆两两不相交 思路:显然的二分半径,然后2-sat去判定就可以 代码: #include ...
- HDU 4548 美素数(打表)
HDU 4548 美素数(打表)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88159#problem/H 题目 ...
随机推荐
- 高阶函数map,filter,reduce的用法
1.filter filter函数的主要用途是对数组元素进行过滤,并返回一个符合条件的元素的数组 let nums = [10,20,30,111,222,333] 选出nums中小于100的数: l ...
- AJAX —— JSON 字符串 与 JSON 对象
一.JSON 字符串转 JSON 对象 ----> JSON.parse(JString); 1 // JSON 字符串转 JSON 对象 ----> JSON.parse(JString ...
- IDEA中web项目maven项目手动打war包的方式
手动打包 https://blog.csdn.net/ibigboy/article/details/90287963 tomcat部署web项目方法 https://www.cnblogs.com/ ...
- 2018-8-10-win10-UWP-序列化
title author date CreateTime categories win10 UWP 序列化 lindexi 2018-08-10 19:16:50 +0800 2018-2-13 17 ...
- java 接口概念及使用
package java11; /* 在任何版本的java中,接口都能定义抽象方法 格式: public abstrace 返回值类型 方法名称(参数列表): 注意事项: 1.接口当中的抽象方法,修饰 ...
- 分布式理论 BASE、CAP、ACID
CAP原理: 在理论计算机科学中,CAP定理(CAP theorem),又被称作布鲁尔定理(Brewer's theorem),它指出对于一个分布式计算系统来说,不可能同时满足以下三点: 一致性(Co ...
- join()、split()
join()用于把数组转化为字符串 var arr=['hello','world','kugou']; document.write(arr.join(''));//helloworldkugou ...
- python 绘制三国人物关系图
author:weizhendong data:2019.12.19 func:绘制三国演义人物关系图 """ import codecs import jieba.po ...
- .NET面试题集锦①
一.前言部分 文中的问题及答案多收集整理自网络,不保证100%准确,还望斟酌采纳. 1.面向对象的思想主要包括什么? 答:任何事物都可以理解为对象,其主要特征: 继承.封装.多态.特点:代码好维护,安 ...
- ASIO
{ 编译ASIO库时,出现编译警告, "Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:\n& ...