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 题目 ...
随机推荐
- while例子 求1到100的和
- 利用 Redis 锁解决高并发问题
这里我们主要利用 Redis 的 setnx 的命令来处理高并发. setnx 有两个参数.第一个参数表示键.第二个参数表示值.如果当前键不存在,那么会插入当前键,将第二个参数做为值.返回 1.如果当 ...
- 01.springboot入门--启用自动配置注解EnableAutoConfiguration
springboot入门 <parent> <groupId>org.springframework.boot</groupId> <artifactId&g ...
- java资料搜索网站
http://yun.java1234.com/ 盘多多 B站 一个集成了很多springboot功能的地址 https://gitbub.com/runzhenghengbin/SpringBoot ...
- Syntax behind sorted(key=lambda :)
I think all of the answers here cover the core of what the lambda function does in the context of so ...
- Vue.js----更换头像不实时更新问题
原因 导致问题的原因是缓存造成的,因为你图片变了但是读取头像的地址还会没有变化的 解决思路 所以解决的思路就是上传之后让图片地址改变,那么我们就可以在上传的时候给地址加上一个时间戳那么久可一达到目的了 ...
- 【leetcode】399. Evaluate Division
题目如下: Equations are given in the format A / B = k, whereA and B are variables represented as strings ...
- QT中视图(setViewport)和窗口(setWindow) 小总结
参考博客: https://blog.csdn.net/weixin_39583140/article/details/92798127 https://blog.csdn.net/u01244271 ...
- UITableViewCell的移动
看到Metro大都会 这个App中扣款顺序有个cell可以移动,于是觉得是时候回忆一下UITableView的基本使用了.其实他这个移动cell的功能是系统自带的. 代码主要是这样: // // Vi ...
- JS中字符串的常见属性及方法
1.属性 1.1.length var txt = "abc 123"; console.log(txt.length); 2.方法 2.1.返回字符位置(indexOf()) 该 ...