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 题目 ...
随机推荐
- JVM(2)之 JAVA堆
开发十年,就只剩下这套架构体系了! >>> 之前我们说到了栈,它在内存中是连续的空间:保存一个个的栈帧,对应一次次方法的调用:还讲到了他是保存对象的引用,那么对象存在哪里呢?我们 ...
- SpringMVC表单或Json中日期字符串与JavaBean的Date类型的转换
SpringMVC表单或Json中日期字符串与JavaBean的Date类型的转换 场景一:表单中的日期字符串和JavaBean的Date类型的转换 在使用SpringMVC的时候,经常会遇到表单中的 ...
- Codeforces 735E 树形DP
题意:给你一棵树,你需要在这棵树上选择一些点染成黑色,要求染色之后树中任意节点到离它最近的黑色节点的距离不超过m,问满足这种条件的染色方案有多少种? 思路:设dp[x][i]为以x为根的子树中,离x点 ...
- ubuntu16.04的一系列安装
1.安装ubuntu https://blog.csdn.net/weixin_40494464/article/details/81010256 2.ubuntu里选择简体中文 https://bl ...
- winform 自定义控件属性在属性面板中显示
Jan.David Nothing is impossible, the word itself says 'I'm possible'!" — Audrey Hepburn winform ...
- 11.IPFS搭建及上传获取数据——2019年12月12日
title: ipfs使用 date: "2019-09-26 10:17:16" tags: ipfs categories: 技术驿站 1.mac安装ipfs--使用npm工具 ...
- java资料搜索网站
http://yun.java1234.com/ 盘多多 B站 一个集成了很多springboot功能的地址 https://gitbub.com/runzhenghengbin/SpringBoot ...
- cookie和session的区别有哪些
前言: cookie和session有着千丝万缕的联系,本文将详细介绍2者的区别. 1.存储位置不同 cookie的数据信息存放在客户端浏览器上. session的数据信息存放在服务器上. 2.存储容 ...
- list的过滤操作
假设 l = ['abc', 'mn', 'aq', 'liuming'] 我要过滤出以a开头的元素,方法有以下两种 方法1: l = ['abc', 'mn', 'aq', 'liuming'] l ...
- hdu 2732 Leapin' Lizards (最大流 拆点建图)
Problem Description Your platoon of wandering lizards has entered a strange room in the labyrinth yo ...